Skip to content

Commit 96454ac

Browse files
committed
import-project feature
1 parent 25f4a82 commit 96454ac

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,25 @@
1717

1818
Add repo
1919

20-
./bin/gitlab-projects add-project gitlab/gitlab-ci.git
20+
./bin/gitlab-projects add-project gitlab/gitlab-ci.git
2121

2222
Remove repo
2323

24-
./bin/gitlab-projects rm-project gitlab/gitlab-ci.git
24+
./bin/gitlab-projects rm-project gitlab/gitlab-ci.git
25+
26+
Import repo
27+
28+
./bin/gitlab-projects import-project https://github.com/randx/six.git
29+
2530

2631
### Keys:
2732

2833

2934
Add key
3035

31-
./bin/gitlab-keys add-key key-782 "ssh-rsa AAAAx321..."
36+
./bin/gitlab-keys add-key key-782 "ssh-rsa AAAAx321..."
3237

3338
Remove key
3439

35-
./bin/gitlab-keys rm-key key-23 "ssh-rsa AAAAx321..."
40+
./bin/gitlab-keys rm-key key-23 "ssh-rsa AAAAx321..."
3641

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

lib/gitlab_projects.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def exec
1717
case @command
1818
when 'add-project'; add_project
1919
when 'rm-project'; rm_project
20+
when 'import-project'; import_project
2021
else
2122
puts 'not allowed'
2223
end
@@ -33,4 +34,10 @@ def add_project
3334
def rm_project
3435
FileUtils.rm_rf(full_path)
3536
end
37+
38+
def import_project
39+
dir = @project_name.match(/[a-zA-Z\.\_\-]+\.git$/).to_s
40+
cmd = "cd #{@repos_path} && git clone --bare #{@project_name} #{dir} && ln -s #{@hook_path} #{@repos_path}/#{dir}/hooks/post-receive"
41+
system(cmd)
42+
end
3643
end

0 commit comments

Comments
 (0)