Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync branches to DB immediately when handle git hook calling #29493

Merged
merged 12 commits into from
Mar 6, 2024
Prev Previous commit
Next Next commit
Update routers/private/hook_post_receive.go
Co-authored-by: Lunny Xiao <[email protected]>
  • Loading branch information
wolfogre and lunny committed Mar 1, 2024
commit 3d6882822f73c15191c6c7b970da272e0281c36b
13 changes: 8 additions & 5 deletions routers/private/hook_post_receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,15 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
return
}
}
commit, err := gitRepo.GetCommit(update.NewCommitID)
if err != nil {
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
var commit *git.Commit
if !opts.IsDelRef() {
commit, err := gitRepo.GetCommit(update.NewCommitID)
if err != nil {
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
Err: fmt.Sprintf("Failed to get commit %s in repository: %s/%s Error: %v", update.NewCommitID, ownerName, repoName, err),
})
return
})
return
}
}
wolfogre marked this conversation as resolved.
Show resolved Hide resolved
if err := repo_service.SyncBranchToDB(ctx, repo.ID, update.PusherID, update.RefFullName.BranchName(), commit); err != nil {
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
Expand Down
Loading