File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ Remove repo:
31
31
32
32
./bin/gitlab-projects rm-project gitlab/gitlab-ci.git
33
33
34
+ List repos:
35
+
36
+ ./bin/gitlab-projects list-projects
37
+
34
38
Import repo:
35
39
36
40
# Default timeout is 2 minutes
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ require_relative '../lib/gitlab_init'
11
11
#
12
12
# /bin/gitlab-projects rm-project gitlab/gitlab-ci.git
13
13
#
14
+ # /bin/gitlab-projects list-projects
15
+ #
14
16
# /bin/gitlab-projects mv-project gitlab/gitlab-ci.git randx/fork.git
15
17
#
16
18
# /bin/gitlab-projects fork-project gitlab/gitlab-ci.git randx
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def initialize
31
31
@command = ARGV . shift
32
32
@project_name = ARGV . shift
33
33
@repos_path = GitlabConfig . new . repos_path
34
- @full_path = File . join ( @repos_path , @project_name )
34
+ @full_path = File . join ( @repos_path , @project_name ) unless @project_name . nil?
35
35
end
36
36
37
37
def exec
@@ -41,6 +41,7 @@ def exec
41
41
when 'create-tag' ; create_tag
42
42
when 'rm-tag' ; rm_tag
43
43
when 'add-project' ; add_project
44
+ when 'list-projects' ; puts list_projects
44
45
when 'rm-project' ; rm_project
45
46
when 'mv-project' ; mv_project
46
47
when 'import-project' ; import_project
@@ -93,6 +94,13 @@ def add_project
93
94
system ( *cmd ) && self . class . create_hooks ( full_path )
94
95
end
95
96
97
+ def list_projects
98
+ $logger. info 'Listing projects'
99
+ Dir . chdir ( repos_path ) do
100
+ next Dir . glob ( '**/*.git' )
101
+ end
102
+ end
103
+
96
104
def rm_project
97
105
$logger. info "Removing project #{ @project_name } from <#{ full_path } >."
98
106
FileUtils . rm_rf ( full_path )
Original file line number Diff line number Diff line change 135
135
end
136
136
end
137
137
138
+ describe :list_projects do
139
+ let ( :gl_projects ) do
140
+ build_gitlab_projects ( 'add-project' , "list_test/#{ repo_name } " )
141
+ end
142
+
143
+ before do
144
+ FileUtils . mkdir_p ( tmp_repos_path )
145
+ end
146
+
147
+ it 'should create projects and list them' do
148
+ GitlabProjects . stub ( create_hooks : true )
149
+ gl_projects . exec
150
+ gl_projects . send ( :list_projects ) . should == [ "list_test/#{ repo_name } " ]
151
+ end
152
+ end
153
+
138
154
describe :mv_project do
139
155
let ( :gl_projects ) { build_gitlab_projects ( 'mv-project' , repo_name , 'repo.git' ) }
140
156
let ( :new_repo_path ) { File . join ( tmp_repos_path , 'repo.git' ) }
You can’t perform that action at this time.
0 commit comments