diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-04 10:02:39 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-04 10:02:39 +0200 |
commit | 4908b89495e27b6ea829f32143c7753a6139df32 (patch) | |
tree | 8bc11743d8100772ab6163c58db08fb5a516c66e /lib/gitlab_projects.rb | |
parent | fcf70b91639cc4ee369631cf8fa4ebad4fbf04c8 (diff) | |
download | gitlab-shell-4908b89495e27b6ea829f32143c7753a6139df32.tar.gz |
Project builder
Diffstat (limited to 'lib/gitlab_projects.rb')
-rw-r--r-- | lib/gitlab_projects.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb new file mode 100644 index 0000000..89fb603 --- /dev/null +++ b/lib/gitlab_projects.rb @@ -0,0 +1,35 @@ +require 'open3' +require 'fileutils' +require_relative 'gitlab_config' + +class GitlabProjects + attr_accessor :project_name + + def initialize + @command = ARGV.shift + @project_name = ARGV.shift + @repos_path = GitlabConfig.new.repos_path + @full_path = File.join(@repos_path, @project_name) + end + + def exec + case @command + when 'add-project'; add_project + when 'rm-project'; rm_project + else + puts 'not allowed' + end + end + + protected + + def add_project + FileUtils.mkdir_p(@full_path, mode: 0770 ) + cmd = "cd #{@full_path} && git init --bare" + system(cmd) + end + + def rm_project + FileUtils.rm_rf(@full_path) + end +end |