Commit 6cd167ea authored by David Martin's avatar David Martin

Added list-projects command & spec

list-projects command usage

Single quotes

Use single quotes

Use single quotes
parent 7e74d054
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment