6109daf480
DRY code + fix rubocop Add more test cases Append to changelog DRY changes list find_url service for merge_requests use GET for getting merge request links remove files rename to get_url_service reduce loop add test case for cross project refactor tiny thing update changelog
47 lines
936 B
Ruby
47 lines
936 B
Ruby
module Gitlab
|
|
module Git
|
|
BLANK_SHA = ('0' * 40).freeze
|
|
TAG_REF_PREFIX = "refs/tags/".freeze
|
|
BRANCH_REF_PREFIX = "refs/heads/".freeze
|
|
|
|
class << self
|
|
def ref_name(ref)
|
|
ref.gsub(/\Arefs\/(tags|heads)\//, '')
|
|
end
|
|
|
|
def branch_name(ref)
|
|
ref = ref.to_s
|
|
if self.branch_ref?(ref)
|
|
self.ref_name(ref)
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
def tag_name(ref)
|
|
ref = ref.to_s
|
|
if self.tag_ref?(ref)
|
|
self.ref_name(ref)
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
def tag_ref?(ref)
|
|
ref.start_with?(TAG_REF_PREFIX)
|
|
end
|
|
|
|
def branch_ref?(ref)
|
|
ref.start_with?(BRANCH_REF_PREFIX)
|
|
end
|
|
|
|
def blank_ref?(ref)
|
|
ref == BLANK_SHA
|
|
end
|
|
|
|
def version
|
|
Gitlab::VersionInfo.parse(Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} --version)).first)
|
|
end
|
|
end
|
|
end
|
|
end
|