File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+
3+ #
4+ # GitLab Projects shell. Add/remove projects from /home/git/repositories
5+ #
6+ # Ex.
7+ # /bin/gitlab-projects add-project gitlab/gitlab-ci.git
8+ #
9+ #
10+ ROOT_PATH = File . join ( File . expand_path ( File . dirname ( __FILE__ ) ) , ".." )
11+ require File . join ( ROOT_PATH , 'lib' , 'gitlab_projects' )
12+ GitlabProjects . new . exec
13+
14+ exit
Original file line number Diff line number Diff line change 1+ require 'open3'
2+ require 'fileutils'
3+ require_relative 'gitlab_config'
4+
5+ class GitlabProjects
6+ attr_accessor :project_name
7+
8+ def initialize
9+ @command = ARGV . shift
10+ @project_name = ARGV . shift
11+ @repos_path = GitlabConfig . new . repos_path
12+ @full_path = File . join ( @repos_path , @project_name )
13+ end
14+
15+ def exec
16+ case @command
17+ when 'add-project' ; add_project
18+ when 'rm-project' ; rm_project
19+ else
20+ puts 'not allowed'
21+ end
22+ end
23+
24+ protected
25+
26+ def add_project
27+ FileUtils . mkdir_p ( @full_path , mode : 0770 )
28+ cmd = "cd #{ @full_path } && git init --bare"
29+ system ( cmd )
30+ end
31+
32+ def rm_project
33+ FileUtils . rm_rf ( @full_path )
34+ end
35+ end
You can’t perform that action at this time.
0 commit comments