use gitRepo.GetCommit directly
and give it a commitID instead of a branchName (a bit more correct and faster)
This commit is contained in:
parent
286d09203f
commit
0a53eb838d
2 changed files with 2 additions and 4 deletions
|
@ -142,9 +142,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||||
commitIDs = append(commitIDs, update.NewCommitID)
|
commitIDs = append(commitIDs, update.NewCommitID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo_service.SyncBranchesToDB(ctx, repo.ID, opts.UserID, branchNames, commitIDs, func(commitID string) (*git.Commit, error) {
|
if err := repo_service.SyncBranchesToDB(ctx, repo.ID, opts.UserID, branchNames, commitIDs, gitRepo.GetCommit); err != nil {
|
||||||
return gitRepo.GetCommit(commitID)
|
|
||||||
}); err != nil {
|
|
||||||
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
|
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
|
||||||
Err: fmt.Sprintf("Failed to sync branch to DB in repository: %s/%s Error: %v", ownerName, repoName, err),
|
Err: fmt.Sprintf("Failed to sync branch to DB in repository: %s/%s Error: %v", ownerName, repoName, err),
|
||||||
})
|
})
|
||||||
|
|
|
@ -283,7 +283,7 @@ func SyncBranchesToDB(ctx context.Context, repoID, pusherID int64, branchNames,
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
commit, err := getCommit(branchName)
|
commit, err := getCommit(commitID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get commit of %s failed: %v", branchName, err)
|
return fmt.Errorf("get commit of %s failed: %v", branchName, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue