From 290064aa4904a2a77cb010b38fd0752b05b87fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Passerini?= Date: Thu, 13 Oct 2016 13:48:00 +0200 Subject: [PATCH] Fixes #100 --- .../instance/testCloneOntoExistingDirectory.st | 10 ++++++++++ .../IceMCGitRepository.class/instance/validate.st | 5 ++--- .../IceRepository.class/instance/repository..st | 11 ++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 Iceberg-Tests.package/IceRepositoryTest.class/instance/testCloneOntoExistingDirectory.st diff --git a/Iceberg-Tests.package/IceRepositoryTest.class/instance/testCloneOntoExistingDirectory.st b/Iceberg-Tests.package/IceRepositoryTest.class/instance/testCloneOntoExistingDirectory.st new file mode 100644 index 0000000000..2631f45791 --- /dev/null +++ b/Iceberg-Tests.package/IceRepositoryTest.class/instance/testCloneOntoExistingDirectory.st @@ -0,0 +1,10 @@ +tests - create repository +testCloneOntoExistingDirectory + | location | + + location := repository location. + location ensureCreateDirectory. + + repository createRepository. + self assert: (location / '.git') exists. + diff --git a/Iceberg.package/IceMCGitRepository.class/instance/validate.st b/Iceberg.package/IceMCGitRepository.class/instance/validate.st index b7a83f6f24..cbd0c2bc61 100644 --- a/Iceberg.package/IceMCGitRepository.class/instance/validate.st +++ b/Iceberg.package/IceMCGitRepository.class/instance/validate.st @@ -1,6 +1,5 @@ initialize local repository validate "TODO: More validations are needed, see: https://github.com/npasserini/iceberg/issues/27." - (self isGitRepository: directory) - ifFalse: [ MCFileTreeGitError new - signal: 'is not a git repository: ' , directory ]. \ No newline at end of file + (((self repositoryDirectory / '.git') exists) and: [self isGitRepository: self repositoryDirectory ]) + ifFalse: [ MCFileTreeGitError new signal: 'is not a git repository: ' , directory ]. \ No newline at end of file diff --git a/Iceberg.package/IceRepository.class/instance/repository..st b/Iceberg.package/IceRepository.class/instance/repository..st index ec49c9a666..1abed4ebac 100644 --- a/Iceberg.package/IceRepository.class/instance/repository..st +++ b/Iceberg.package/IceRepository.class/instance/repository..st @@ -2,14 +2,15 @@ repository handling repository: anMCRepository repository := anMCRepository. - self location exists + (self location exists not or: [ self location hasChildren not ]) ifTrue: [ + repository cloneRepository. + repository validate + ] + ifFalse: [ repository validate. branch ifNil: [ self branchName: repository currentBranch. ] - ifNotNil: [ self checkoutBranch: branch name ]] - ifFalse: [ - repository cloneRepository. - repository validate + ifNotNil: [ self checkoutBranch: branch name ] ] \ No newline at end of file