summaryrefslogtreecommitdiffstats
path: root/modules/git/utils.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-11-24 13:16:59 +0800
committertechknowlogick <techknowlogick@gitea.io>2019-11-24 00:16:59 -0500
commit8ab35eefc4ff5db3f2f0a62f6f0272eae9be0585 (patch)
tree5249bcee68fb96652adc8f7dd46b604cbf15cd5e /modules/git/utils.go
parente3f22ad2cca094cba057683f35f8536e3f71a582 (diff)
downloadgitea-8ab35eefc4ff5db3f2f0a62f6f0272eae9be0585.tar.gz
gitea-8ab35eefc4ff5db3f2f0a62f6f0272eae9be0585.zip
Move mirror sync actions to notification (#9022)
* Move mirror sync actions to notification * fix lint
Diffstat (limited to 'modules/git/utils.go')
-rw-r--r--modules/git/utils.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/git/utils.go b/modules/git/utils.go
index e791f16041..2b823366b6 100644
--- a/modules/git/utils.go
+++ b/modules/git/utils.go
@@ -88,6 +88,19 @@ func RefEndName(refStr string) string {
return refStr
}
+// SplitRefName splits a full refname to reftype and simple refname
+func SplitRefName(refStr string) (string, string) {
+ if strings.HasPrefix(refStr, BranchPrefix) {
+ return BranchPrefix, refStr[len(BranchPrefix):]
+ }
+
+ if strings.HasPrefix(refStr, TagPrefix) {
+ return TagPrefix, refStr[len(TagPrefix):]
+ }
+
+ return "", refStr
+}
+
// ParseBool returns the boolean value represented by the string as per git's git_config_bool
// true will be returned for the result if the string is empty, but valid will be false.
// "true", "yes", "on" are all true, true