summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-13 10:18:07 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-13 10:18:07 +0200
commit01a74127435fe32ef5aa6bf43000796c6f9c2ab6 (patch)
tree62bb446c2a5a2d6ec1cc48b4576d7a231ec6ad0f
parent0f4ad24ff2f3ff375153b2e6535f1fd2ca467401 (diff)
downloadgitlab-shell-01a74127435fe32ef5aa6bf43000796c6f9c2ab6.tar.gz
Dont import repo if exists
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--lib/gitlab_projects.rb3
-rw-r--r--spec/gitlab_projects_spec.rb9
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index 38a3a7d..3afbe64 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -92,6 +92,9 @@ class GitlabProjects
# Import project via git clone --bare
# URL must be publicly cloneable
def import_project
+ # Skip import if repo already exists
+ return false if File.exists?(full_path)
+
@source = ARGV.shift
# timeout for clone
diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb
index c60febb..946e5c6 100644
--- a/spec/gitlab_projects_spec.rb
+++ b/spec/gitlab_projects_spec.rb
@@ -213,6 +213,15 @@ describe GitlabProjects do
end
end
+ context 'already exists' do
+ let(:gl_projects) { build_gitlab_projects('import-project', repo_name, 'https://github.com/randx/six.git') }
+
+ it 'should import only once' do
+ gl_projects.exec.should be_true
+ gl_projects.exec.should be_false
+ end
+ end
+
context 'timeout' do
let(:gl_projects) { build_gitlab_projects('import-project', repo_name, 'https://github.com/gitlabhq/gitlabhq.git', '1') }