diff options
author | David Martin <david.martin@feedhenry.com> | 2014-09-17 11:35:16 +0100 |
---|---|---|
committer | David Martin <david.martin@feedhenry.com> | 2014-10-15 10:28:12 +0100 |
commit | 6cd167eaac7b764bcaefe31a9144dd38992cc9ab (patch) | |
tree | 9528e100c69d4e2142edfaaa44701a693546ee4d | |
parent | 7e74d0547255a9cf60f00b9d9133aa8b2c546507 (diff) | |
download | gitlab-shell-6cd167eaac7b764bcaefe31a9144dd38992cc9ab.tar.gz |
Added list-projects command & spec
list-projects command usage
Single quotes
Use single quotes
Use single quotes
-rw-r--r-- | README.md | 4 | ||||
-rwxr-xr-x | bin/gitlab-projects | 2 | ||||
-rw-r--r-- | lib/gitlab_projects.rb | 10 | ||||
-rw-r--r-- | spec/gitlab_projects_spec.rb | 16 |
4 files changed, 31 insertions, 1 deletions
@@ -31,6 +31,10 @@ Remove repo: ./bin/gitlab-projects rm-project gitlab/gitlab-ci.git +List repos: + + ./bin/gitlab-projects list-projects + Import repo: # Default timeout is 2 minutes diff --git a/bin/gitlab-projects b/bin/gitlab-projects index 01de20b..c354fe5 100755 --- a/bin/gitlab-projects +++ b/bin/gitlab-projects @@ -11,6 +11,8 @@ require_relative '../lib/gitlab_init' # # /bin/gitlab-projects rm-project gitlab/gitlab-ci.git # +# /bin/gitlab-projects list-projects +# # /bin/gitlab-projects mv-project gitlab/gitlab-ci.git randx/fork.git # # /bin/gitlab-projects fork-project gitlab/gitlab-ci.git randx diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb index 58bbd28..82ae519 100644 --- a/lib/gitlab_projects.rb +++ b/lib/gitlab_projects.rb @@ -31,7 +31,7 @@ class GitlabProjects @command = ARGV.shift @project_name = ARGV.shift @repos_path = GitlabConfig.new.repos_path - @full_path = File.join(@repos_path, @project_name) + @full_path = File.join(@repos_path, @project_name) unless @project_name.nil? end def exec @@ -41,6 +41,7 @@ class GitlabProjects when 'create-tag'; create_tag when 'rm-tag'; rm_tag when 'add-project'; add_project + when 'list-projects'; puts list_projects when 'rm-project'; rm_project when 'mv-project'; mv_project when 'import-project'; import_project @@ -93,6 +94,13 @@ class GitlabProjects system(*cmd) && self.class.create_hooks(full_path) end + def list_projects + $logger.info 'Listing projects' + Dir.chdir(repos_path) do + next Dir.glob('**/*.git') + end + end + def rm_project $logger.info "Removing project #{@project_name} from <#{full_path}>." FileUtils.rm_rf(full_path) diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb index 0060fa9..a592e62 100644 --- a/spec/gitlab_projects_spec.rb +++ b/spec/gitlab_projects_spec.rb @@ -135,6 +135,22 @@ describe GitlabProjects do end end + describe :list_projects do + let(:gl_projects) do + build_gitlab_projects('add-project', "list_test/#{repo_name}") + end + + before do + FileUtils.mkdir_p(tmp_repos_path) + end + + it 'should create projects and list them' do + GitlabProjects.stub(create_hooks: true) + gl_projects.exec + gl_projects.send(:list_projects).should == ["list_test/#{repo_name}"] + end + end + describe :mv_project do let(:gl_projects) { build_gitlab_projects('mv-project', repo_name, 'repo.git') } let(:new_repo_path) { File.join(tmp_repos_path, 'repo.git') } |