summaryrefslogtreecommitdiff
path: root/lib/gitlab/git
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2017-08-22 13:54:14 +0200
committerJacob Vosmaer <jacob@gitlab.com>2017-08-23 10:45:20 +0200
commit65f83941c39c14c2af9da5064393545ea2f7b3e5 (patch)
treec18f36d6ec757954ac7af3b9674bbb20b2ac45c6 /lib/gitlab/git
parent9b9309329207449ef022bdcf06bff5f8eae36032 (diff)
downloadgitlab-ce-65f83941c39c14c2af9da5064393545ea2f7b3e5.tar.gz
Make gl_repository a G::G::Repository attribute
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r--lib/gitlab/git/hook.rb13
-rw-r--r--lib/gitlab/git/repository.rb5
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/gitlab/git/hook.rb b/lib/gitlab/git/hook.rb
index 8f0c377ef4f..08cede42ba2 100644
--- a/lib/gitlab/git/hook.rb
+++ b/lib/gitlab/git/hook.rb
@@ -6,15 +6,18 @@ module Gitlab
module Git
class Hook
GL_PROTOCOL = 'web'.freeze
- attr_reader :name, :repo_path, :path
+ attr_reader :name, :path, :repository
- def initialize(name, project)
+ def initialize(name, repository)
@name = name
- @project = project
- @repo_path = project.repository.path
+ @repository = repository
@path = File.join(repo_path.strip, 'hooks', name)
end
+ def repo_path
+ repository.path
+ end
+
def exists?
File.exist?(path)
end
@@ -44,7 +47,7 @@ module Gitlab
'GL_ID' => gl_id,
'PWD' => repo_path,
'GL_PROTOCOL' => GL_PROTOCOL,
- 'GL_REPOSITORY' => Gitlab::GlRepository.gl_repository(@project, false)
+ 'GL_REPOSITORY' => repository.gl_repository
}
options = {
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index eb3731ba35a..976ea7e4035 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -49,13 +49,14 @@ module Gitlab
# Rugged repo object
attr_reader :rugged
- attr_reader :storage
+ attr_reader :storage, :gl_repository, :relative_path
# 'path' must be the path to a _bare_ git repository, e.g.
# /path/to/my-repo.git
- def initialize(storage, relative_path)
+ def initialize(storage, relative_path, gl_repository)
@storage = storage
@relative_path = relative_path
+ @gl_repository = gl_repository
storage_path = Gitlab.config.repositories.storages[@storage]['path']
@path = File.join(storage_path, @relative_path)