From 419804fd4d5cb655a51f245010b8eb1163b26bc2 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 13 Jun 2023 14:05:28 +0800 Subject: Fix compatible for webhook ref type (#25195) Fix #25185 Caused by #24634 --- modules/git/ref.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'modules/git') diff --git a/modules/git/ref.go b/modules/git/ref.go index 73095f8dbe..ad251515e7 100644 --- a/modules/git/ref.go +++ b/modules/git/ref.go @@ -163,6 +163,7 @@ func (ref RefName) ShortName() string { } // RefGroup returns the group type of the reference +// Using the name of the directory under .git/refs func (ref RefName) RefGroup() string { if ref.IsBranch() { return "heads" @@ -182,6 +183,19 @@ func (ref RefName) RefGroup() string { return "" } +// RefType returns the simple ref type of the reference, e.g. branch, tag +// It's differrent from RefGroup, which is using the name of the directory under .git/refs +// Here we using branch but not heads, using tag but not tags +func (ref RefName) RefType() string { + var refType string + if ref.IsBranch() { + refType = "branch" + } else if ref.IsTag() { + refType = "tag" + } + return refType +} + // RefURL returns the absolute URL for a ref in a repository func RefURL(repoURL, ref string) string { refFullName := RefName(ref) -- cgit v1.2.3