summaryrefslogtreecommitdiff
path: root/lib/gitlab_projects.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab_projects.rb')
-rw-r--r--lib/gitlab_projects.rb35
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