summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-02-05 16:29:24 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-02-05 16:29:24 +0200
commit96454ac5894b97bd9d94877524c77efa5d82fa14 (patch)
tree6a71ba7b86be09acec71452f771b886cc7479112
parent25f4a829e912b0d94b5a8c1cd9fe01f029a31e43 (diff)
downloadgitlab-shell-96454ac5894b97bd9d94877524c77efa5d82fa14.tar.gz
import-project feature
-rw-r--r--README.md13
-rw-r--r--VERSION1
-rw-r--r--lib/gitlab_projects.rb7
3 files changed, 17 insertions, 4 deletions
diff --git a/README.md b/README.md
index 4c5b3d4..104acc9 100644
--- a/README.md
+++ b/README.md
@@ -17,20 +17,25 @@
Add repo
- ./bin/gitlab-projects add-project gitlab/gitlab-ci.git
+ ./bin/gitlab-projects add-project gitlab/gitlab-ci.git
Remove repo
- ./bin/gitlab-projects rm-project gitlab/gitlab-ci.git
+ ./bin/gitlab-projects rm-project gitlab/gitlab-ci.git
+
+Import repo
+
+ ./bin/gitlab-projects import-project https://github.com/randx/six.git
+
### Keys:
Add key
- ./bin/gitlab-keys add-key key-782 "ssh-rsa AAAAx321..."
+ ./bin/gitlab-keys add-key key-782 "ssh-rsa AAAAx321..."
Remove key
- ./bin/gitlab-keys rm-key key-23 "ssh-rsa AAAAx321..."
+ ./bin/gitlab-keys rm-key key-23 "ssh-rsa AAAAx321..."
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..3eefcb9
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+1.0.0
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index 83f542a..33b1c21 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -17,6 +17,7 @@ class GitlabProjects
case @command
when 'add-project'; add_project
when 'rm-project'; rm_project
+ when 'import-project'; import_project
else
puts 'not allowed'
end
@@ -33,4 +34,10 @@ class GitlabProjects
def rm_project
FileUtils.rm_rf(full_path)
end
+
+ def import_project
+ dir = @project_name.match(/[a-zA-Z\.\_\-]+\.git$/).to_s
+ cmd = "cd #{@repos_path} && git clone --bare #{@project_name} #{dir} && ln -s #{@hook_path} #{@repos_path}/#{dir}/hooks/post-receive"
+ system(cmd)
+ end
end