Skip to content

Commit

Permalink
Don't ignore error in getMergeCommit (#1843)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethantkoenig authored and appleboy committed Jun 1, 2017
1 parent 336e311 commit a977ab7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit a977ab7

Please sign in to comment.