diff options
-rw-r--r-- | lib/gitlab_projects.rb | 3 | ||||
-rw-r--r-- | spec/gitlab_projects_spec.rb | 9 |
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') } |