0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-19 16:31:41 +01:00

Don't ignore error in getMergeCommit (#1843)

This commit is contained in:
Ethan Koenig 2017-05-31 20:51:24 -04:00 committed by Bo-Yi Wu
parent 336e311a7c
commit a977ab7889

View file

@ -501,9 +501,15 @@ func (pr *PullRequest) getMergeCommit() (*git.Commit, error) {
return nil, fmt.Errorf("git merge-base --is-ancestor: %v %v", stderr, err)
}
// We can ignore this error since we only get here when there's a valid commit in headFile
commitID, _ := ioutil.ReadFile(pr.BaseRepo.RepoPath() + "/" + headFile)
cmd := string(commitID)[:40] + ".." + pr.BaseBranch
commitIDBytes, err := ioutil.ReadFile(pr.BaseRepo.RepoPath() + "/" + headFile)
if err != nil {
return nil, fmt.Errorf("ReadFile(%s): %v", headFile, err)
}
commitID := string(commitIDBytes)
if len(commitID) < 40 {
return nil, fmt.Errorf(`ReadFile(%s): invalid commit-ID "%s"`, headFile, commitID)
}
cmd := commitID[:40] + ".." + pr.BaseBranch
// Get the commit from BaseBranch where the pull request got merged
mergeCommit, stderr, err := process.GetManager().ExecDirEnv(-1, "", fmt.Sprintf("isMerged (git rev-list --ancestry-path --merges --reverse): %d", pr.BaseRepo.ID),