aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2024-03-11 14:42:50 +0800
committerGitHub <noreply@github.com>2024-03-11 06:42:50 +0000
commite6d141182fbd1c56cab3f9369ee4d2a3deb9ab9f (patch)
tree6ae53136c1d0f66e839fab85c6ad5d304a7271b1
parent4129e0e79bbf30e4297efd33feb2602c40322d10 (diff)
downloadgitea-e6d141182fbd1c56cab3f9369ee4d2a3deb9ab9f.tar.gz
gitea-e6d141182fbd1c56cab3f9369ee4d2a3deb9ab9f.zip
Sync branches first (#29714)
Follow #29493. Sync branches to DB first, then trigger push events.
-rw-r--r--routers/private/hook_post_receive.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/routers/private/hook_post_receive.go b/routers/private/hook_post_receive.go
index c5504126f8..3dad39f7b1 100644
--- a/routers/private/hook_post_receive.go
+++ b/routers/private/hook_post_receive.go
@@ -82,19 +82,6 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
}
if repo != nil && len(updates) > 0 {
- if err := repo_service.PushUpdates(updates); err != nil {
- log.Error("Failed to Update: %s/%s Total Updates: %d", ownerName, repoName, len(updates))
- for i, update := range updates {
- log.Error("Failed to Update: %s/%s Update: %d/%d: Branch: %s", ownerName, repoName, i, len(updates), update.RefFullName.BranchName())
- }
- 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),
- })
- return
- }
-
branchesToSync := make([]*repo_module.PushUpdateOptions, 0, len(updates))
for _, update := range updates {
if !update.RefFullName.IsBranch() {
@@ -151,6 +138,19 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
return
}
}
+
+ if err := repo_service.PushUpdates(updates); err != nil {
+ log.Error("Failed to Update: %s/%s Total Updates: %d", ownerName, repoName, len(updates))
+ for i, update := range updates {
+ log.Error("Failed to Update: %s/%s Update: %d/%d: Branch: %s", ownerName, repoName, i, len(updates), update.RefFullName.BranchName())
+ }
+ 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),
+ })
+ return
+ }
}
// Handle Push Options