Sync branches first (gitea#29714)
Follow gitea#29493. Sync branches to DB first, then trigger push events.
This commit is contained in:
parent
66a135f6f2
commit
375222a145
1 changed files with 13 additions and 13 deletions
|
@ -82,19 +82,6 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if repo != nil && len(updates) > 0 {
|
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))
|
branchesToSync := make([]*repo_module.PushUpdateOptions, 0, len(updates))
|
||||||
for _, update := range updates {
|
for _, update := range updates {
|
||||||
if !update.RefFullName.IsBranch() {
|
if !update.RefFullName.IsBranch() {
|
||||||
|
@ -149,6 +136,19 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||||
return
|
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
|
// Handle Push Options
|
||||||
|
|
Loading…
Reference in a new issue