summaryrefslogtreecommitdiffstats
path: root/routers/private
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 /routers/private
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 'routers/private')
-rw-r--r--routers/private/hook.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/routers/private/hook.go b/routers/private/hook.go
index 6cdc5393f4..2bccca3e3e 100644
--- a/routers/private/hook.go
+++ b/routers/private/hook.go
@@ -436,6 +436,18 @@ func HookPostReceive(ctx *macaron.Context, opts private.HookOptions) {
}
}
+ // Push Options
+ if repo != nil && len(opts.GitPushOptions) > 0 {
+ repo.IsPrivate = opts.GitPushOptions.Bool(private.GitPushOptionRepoPrivate, repo.IsPrivate)
+ repo.IsTemplate = opts.GitPushOptions.Bool(private.GitPushOptionRepoTemplate, repo.IsTemplate)
+ if err := models.UpdateRepositoryCols(repo, "is_private", "is_template"); err != nil {
+ log.Error("Failed to Update: %s/%s Error: %v", ownerName, repoName, err)
+ ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
+ Err: fmt.Sprintf("Failed to Update: %s/%s Error: %v", ownerName, repoName, err),
+ })
+ }
+ }
+
results := make([]private.HookPostReceiveBranchResult, 0, len(opts.OldCommitIDs))
// We have to reload the repo in case its state is changed above