@@ -16,6 +16,12 @@ class GitlabProjects
1616 # Ex /home/git/repositories/test.git
1717 attr_reader :full_path
1818
19+ def self . create_hooks ( path )
20+ hook = File . join ( path , 'hooks' , 'update' )
21+ File . delete ( hook ) if File . exists? ( hook )
22+ File . symlink ( File . join ( ROOT_PATH , 'hooks' , 'update' ) , hook )
23+ end
24+
1925 def initialize
2026 @command = ARGV . shift
2127 @project_name = ARGV . shift
@@ -74,13 +80,7 @@ def add_project
7480 $logger. info "Adding project #{ @project_name } at <#{ full_path } >."
7581 FileUtils . mkdir_p ( full_path , mode : 0770 )
7682 cmd = %W( git --git-dir=#{ full_path } init --bare )
77- system ( *cmd ) && create_hooks ( full_path )
78- end
79-
80- def create_hooks ( path )
81- hook = File . join ( path , 'hooks' , 'update' )
82- File . delete ( hook ) if File . exists? ( hook )
83- File . symlink ( File . join ( ROOT_PATH , 'hooks' , 'update' ) , hook )
83+ system ( *cmd ) && self . class . create_hooks ( full_path )
8484 end
8585
8686 def rm_project
@@ -94,7 +94,7 @@ def import_project
9494 @source = ARGV . shift
9595 $logger. info "Importing project #{ @project_name } from <#{ @source } > to <#{ full_path } >."
9696 cmd = %W( git clone --bare -- #{ @source } #{ full_path } )
97- system ( *cmd ) && create_hooks ( full_path )
97+ system ( *cmd ) && self . class . create_hooks ( full_path )
9898 end
9999
100100 # Move repository from one directory to another
@@ -156,7 +156,7 @@ def fork_project
156156
157157 $logger. info "Forking project from <#{ full_path } > to <#{ full_destination_path } >."
158158 cmd = %W( git clone --bare -- #{ full_path } #{ full_destination_path } )
159- system ( *cmd ) && create_hooks ( full_destination_path )
159+ system ( *cmd ) && self . class . create_hooks ( full_destination_path )
160160 end
161161
162162 def update_head
0 commit comments