aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/hook.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-10-12 13:42:10 +0800
committerGitHub <noreply@github.com>2024-10-12 05:42:10 +0000
commitafa8dd45af29f529f3695b4d2bab7ed98ac830db (patch)
tree88773f35c396edf78ad8910fd9e068ca5f2eadcc /cmd/hook.go
parent900ac622514081b90e08135cab175d5d1ea1bc9d (diff)
downloadgitea-afa8dd45af29f529f3695b4d2bab7ed98ac830db.tar.gz
gitea-afa8dd45af29f529f3695b4d2bab7ed98ac830db.zip
Make git push options accept short name (#32245)
Just like what most CLI parsers do: `--opt` means `opt=true` Then users could use `-o force-push` as `-o force-push=true`
Diffstat (limited to 'cmd/hook.go')
-rw-r--r--cmd/hook.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/cmd/hook.go b/cmd/hook.go
index 11d0d072c9..578380ab40 100644
--- a/cmd/hook.go
+++ b/cmd/hook.go
@@ -591,8 +591,9 @@ Gitea or set your environment appropriately.`, "")
// S: ... ...
// S: flush-pkt
hookOptions := private.HookOptions{
- UserName: pusherName,
- UserID: pusherID,
+ UserName: pusherName,
+ UserID: pusherID,
+ GitPushOptions: make(map[string]string),
}
hookOptions.OldCommitIDs = make([]string, 0, hookBatchSize)
hookOptions.NewCommitIDs = make([]string, 0, hookBatchSize)
@@ -617,8 +618,6 @@ Gitea or set your environment appropriately.`, "")
hookOptions.RefFullNames = append(hookOptions.RefFullNames, git.RefName(t[2]))
}
- hookOptions.GitPushOptions = make(map[string]string)
-
if hasPushOptions {
for {
rs, err = readPktLine(ctx, reader, pktLineTypeUnknow)
@@ -629,11 +628,7 @@ Gitea or set your environment appropriately.`, "")
if rs.Type == pktLineTypeFlush {
break
}
-
- kv := strings.SplitN(string(rs.Data), "=", 2)
- if len(kv) == 2 {
- hookOptions.GitPushOptions[kv[0]] = kv[1]
- }
+ hookOptions.GitPushOptions.AddFromKeyValue(string(rs.Data))
}
}