summaryrefslogtreecommitdiffstats
path: root/models/pull.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-05-31 20:51:24 -0400
committerBo-Yi Wu <appleboy.tw@gmail.com>2017-05-31 19:51:24 -0500
commita977ab7889e1cd6accaa401ad2a25f4f3c4c4dd6 (patch)
treee66ec342337a4f909981aa465be6cf7c58c12ee1 /models/pull.go
parent336e311a7c20263f8269b09321eb5f6a65e64016 (diff)
downloadgitea-a977ab7889e1cd6accaa401ad2a25f4f3c4c4dd6.tar.gz
gitea-a977ab7889e1cd6accaa401ad2a25f4f3c4c4dd6.zip
Don't ignore error in getMergeCommit (#1843)
Diffstat (limited to 'models/pull.go')
-rw-r--r--models/pull.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/models/pull.go b/models/pull.go
index e85bf56c61..7a636c3c8c 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -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),