summaryrefslogtreecommitdiffstats
path: root/cmd/hook.go
diff options
context:
space:
mode:
authorJohn Olheiser <john.olheiser@gmail.com>2020-08-23 11:02:35 -0500
committerGitHub <noreply@github.com>2020-08-23 17:02:35 +0100
commit43a397ce9ae082e0c6e9367e31743e1cb4d71c20 (patch)
tree191f7510be4041eaa684bba99480ec0e4bc0bf87 /cmd/hook.go
parente7d65cbc6e50d70753f7228c46cbff0cffde7eba (diff)
downloadgitea-43a397ce9ae082e0c6e9367e31743e1cb4d71c20.tar.gz
gitea-43a397ce9ae082e0c6e9367e31743e1cb4d71c20.zip
Initial support for push options (#12169)
* Initial support for push options Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix misspelling 🤦 Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix formatting after conflict resolution * defer close git repo * According the GitLab documentation, git >= 2.10 Signed-off-by: jolheiser <john.olheiser@gmail.com> * Words are hard. Thanks @mrsdizzie :sweat_smile: Co-authored-by: mrsdizzie <info@mrsdizzie.com> * Only update if there are push options Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Diffstat (limited to 'cmd/hook.go')
-rw-r--r--cmd/hook.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmd/hook.go b/cmd/hook.go
index f5658de7cd..863ed832a9 100644
--- a/cmd/hook.go
+++ b/cmd/hook.go
@@ -178,6 +178,7 @@ Gitea or set your environment appropriately.`, "")
GitAlternativeObjectDirectories: os.Getenv(private.GitAlternativeObjectDirectories),
GitObjectDirectory: os.Getenv(private.GitObjectDirectory),
GitQuarantinePath: os.Getenv(private.GitQuarantinePath),
+ GitPushOptions: pushOptions(),
ProtectedBranchID: prID,
IsDeployKey: isDeployKey,
}
@@ -326,6 +327,7 @@ Gitea or set your environment appropriately.`, "")
GitAlternativeObjectDirectories: os.Getenv(private.GitAlternativeObjectDirectories),
GitObjectDirectory: os.Getenv(private.GitObjectDirectory),
GitQuarantinePath: os.Getenv(private.GitQuarantinePath),
+ GitPushOptions: pushOptions(),
}
oldCommitIDs := make([]string, hookBatchSize)
newCommitIDs := make([]string, hookBatchSize)
@@ -438,3 +440,17 @@ func hookPrintResults(results []private.HookPostReceiveBranchResult) {
os.Stderr.Sync()
}
}
+
+func pushOptions() map[string]string {
+ opts := make(map[string]string)
+ if pushCount, err := strconv.Atoi(os.Getenv(private.GitPushOptionCount)); err == nil {
+ for idx := 0; idx < pushCount; idx++ {
+ opt := os.Getenv(fmt.Sprintf("GIT_PUSH_OPTION_%d", idx))
+ kv := strings.SplitN(opt, "=", 2)
+ if len(kv) == 2 {
+ opts[kv[0]] = kv[1]
+ }
+ }
+ }
+ return opts
+}