Module: Gitlab::Git

Defined in:
lib/gitlab/git.rb,
lib/gitlab/git/hook.rb

Defined Under Namespace

Classes: Hook

Constant Summary collapse

BLANK_SHA =
('0' * 40).freeze
TAG_REF_PREFIX =
"refs/tags/".freeze
BRANCH_REF_PREFIX =
"refs/heads/".freeze

Class Method Summary collapse

Class Method Details

.blank_ref?(ref) ⇒ Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/gitlab/git.rb', line 20

def blank_ref?(ref)
  ref == BLANK_SHA
end

.branch_ref?(ref) ⇒ Boolean

Returns:

  • (Boolean)

16
17
18
# File 'lib/gitlab/git.rb', line 16

def branch_ref?(ref)
  ref.start_with?(BRANCH_REF_PREFIX)
end

.ref_name(ref) ⇒ Object


8
9
10
# File 'lib/gitlab/git.rb', line 8

def ref_name(ref)
  ref.gsub(/\Arefs\/(tags|heads)\//, '')
end

.tag_ref?(ref) ⇒ Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/gitlab/git.rb', line 12

def tag_ref?(ref)
  ref.start_with?(TAG_REF_PREFIX)
end

.versionObject


24
25
26
# File 'lib/gitlab/git.rb', line 24

def version
  Gitlab::VersionInfo.parse(Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --version)).first)
end