summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-06-13 02:51:50 -0400
committerGitHub <noreply@github.com>2023-06-13 06:51:50 +0000
commit506c70884a122f92fc722f297f3d775f5d36ba4f (patch)
tree465c453b11ad58a4ddde34d10ca5acf41e818781 /modules
parentf64f5495af50750349e187475c282f1f700beafc (diff)
downloadgitea-506c70884a122f92fc722f297f3d775f5d36ba4f.tar.gz
gitea-506c70884a122f92fc722f297f3d775f5d36ba4f.zip
Fix compatible for webhook ref type (#25195) (#25223)
Backport #25195 by @lunny Fix #25185 Caused by #24634 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/git/ref.go14
1 files changed, 14 insertions, 0 deletions
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)