Browse Source

Add length check for the return string (#1420)

* Add length check for the return string

* Differentiate error paths and logging messages

* Rectify error message
tags/v1.21.12.1
Mura Li Bo-Yi Wu 9 years ago
parent
commit
6a39250579
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      models/pull.go

+ 3
- 1
models/pull.go View File

@@ -507,7 +507,9 @@ func (pr *PullRequest) getMergeCommit() (*git.Commit, error) {
mergeCommit, stderr, err := process.GetManager().ExecDirEnv(-1, "", fmt.Sprintf("isMerged (git rev-list --ancestry-path --merges --reverse): %d", pr.BaseRepo.ID),
[]string{"GIT_INDEX_FILE=" + indexTmpPath, "GIT_DIR=" + pr.BaseRepo.RepoPath()},
"git", "rev-list", "--ancestry-path", "--merges", "--reverse", cmd)

if err == nil && len(mergeCommit) != 40 {
err = fmt.Errorf("unexpected length of output (got:%d bytes) '%s'", len(mergeCommit), mergeCommit)
}
if err != nil {
return nil, fmt.Errorf("git rev-list --ancestry-path --merges --reverse: %v %v", stderr, err)
}


Loading…
Cancel
Save