summaryrefslogtreecommitdiff
path: root/lib/gitlab/git/commit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/git/commit.rb')
-rw-r--r--lib/gitlab/git/commit.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index 6605e896ef1..267107e04e6 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -315,10 +315,18 @@ module Gitlab
#
def ref_names(repo)
refs(repo).map do |ref|
- ref.sub(%r{^refs/(heads|remotes|tags)/}, "")
+ strip_ref_prefix(ref)
end
end
+ def first_ref_by_oid(repo)
+ ref = repo.refs_by_oid(oid: id, limit: 1)&.first
+
+ return unless ref
+
+ strip_ref_prefix(ref)
+ end
+
def message
encode! @message
end
@@ -466,6 +474,10 @@ module Gitlab
commit_id.match?(/\s/)
)
end
+
+ def strip_ref_prefix(ref)
+ ref.sub(%r{^refs/(heads|remotes|tags)/}, "")
+ end
end
end
end