summaryrefslogtreecommitdiff
path: root/lib/gitlab_projects.rb
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-02-25 15:38:41 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-02-26 11:27:43 +0100
commit02b960c988acdc9e1ced6438e5c8778c1b938034 (patch)
tree63904065a7f44d9ad6664ec20750bd2276d93912 /lib/gitlab_projects.rb
parent56e216f33ca0db21336cc8dc1f7e09a834267772 (diff)
downloadgitlab-shell-02b960c988acdc9e1ced6438e5c8778c1b938034.tar.gz
Make GitlabProjects#create_hooks a class method
Diffstat (limited to 'lib/gitlab_projects.rb')
-rw-r--r--lib/gitlab_projects.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index fec204c..a0063aa 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -16,6 +16,12 @@ class GitlabProjects
# Ex /home/git/repositories/test.git
attr_reader :full_path
+ def self.create_hooks(path)
+ hook = File.join(path, 'hooks', 'update')
+ File.delete(hook) if File.exists?(hook)
+ File.symlink(File.join(ROOT_PATH, 'hooks', 'update'), hook)
+ end
+
def initialize
@command = ARGV.shift
@project_name = ARGV.shift
@@ -74,13 +80,7 @@ class GitlabProjects
$logger.info "Adding project #{@project_name} at <#{full_path}>."
FileUtils.mkdir_p(full_path, mode: 0770)
cmd = %W(git --git-dir=#{full_path} init --bare)
- system(*cmd) && create_hooks(full_path)
- end
-
- def create_hooks(path)
- hook = File.join(path, 'hooks', 'update')
- File.delete(hook) if File.exists?(hook)
- File.symlink(File.join(ROOT_PATH, 'hooks', 'update'), hook)
+ system(*cmd) && self.class.create_hooks(full_path)
end
def rm_project
@@ -94,7 +94,7 @@ class GitlabProjects
@source = ARGV.shift
$logger.info "Importing project #{@project_name} from <#{@source}> to <#{full_path}>."
cmd = %W(git clone --bare -- #{@source} #{full_path})
- system(*cmd) && create_hooks(full_path)
+ system(*cmd) && self.class.create_hooks(full_path)
end
# Move repository from one directory to another
@@ -156,7 +156,7 @@ class GitlabProjects
$logger.info "Forking project from <#{full_path}> to <#{full_destination_path}>."
cmd = %W(git clone --bare -- #{full_path} #{full_destination_path})
- system(*cmd) && create_hooks(full_destination_path)
+ system(*cmd) && self.class.create_hooks(full_destination_path)
end
def update_head