Skip to content

Commit 3d68828

Browse files
wolfogrelunny
andauthored
Update routers/private/hook_post_receive.go
Co-authored-by: Lunny Xiao <[email protected]>
1 parent 6bef773 commit 3d68828

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

routers/private/hook_post_receive.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,15 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
116116
return
117117
}
118118
}
119-
commit, err := gitRepo.GetCommit(update.NewCommitID)
120-
if err != nil {
121-
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
119+
var commit *git.Commit
120+
if !opts.IsDelRef() {
121+
commit, err := gitRepo.GetCommit(update.NewCommitID)
122+
if err != nil {
123+
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
122124
Err: fmt.Sprintf("Failed to get commit %s in repository: %s/%s Error: %v", update.NewCommitID, ownerName, repoName, err),
123-
})
124-
return
125+
})
126+
return
127+
}
125128
}
126129
if err := repo_service.SyncBranchToDB(ctx, repo.ID, update.PusherID, update.RefFullName.BranchName(), commit); err != nil {
127130
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{

0 commit comments

Comments
 (0)