Fix pull creation with empty changes (#7920)
* Logs the stderr of git-apply * Add an integration test * Skip testPatch when patch is empty
This commit is contained in:
parent
31f5713a1f
commit
3ac45e3cb5
2 changed files with 36 additions and 7 deletions
|
@ -598,7 +598,7 @@ func (pr *PullRequest) testPatch(e Engine) (err error) {
|
|||
if err != nil {
|
||||
for i := range patchConflicts {
|
||||
if strings.Contains(stderr, patchConflicts[i]) {
|
||||
log.Trace("PullRequest[%d].testPatch (apply): has conflict", pr.ID)
|
||||
log.Trace("PullRequest[%d].testPatch (apply): has conflict: %s", pr.ID, stderr)
|
||||
const prefix = "error: patch failed:"
|
||||
pr.Status = PullRequestStatusConflict
|
||||
pr.ConflictedFiles = make([]string, 0, 5)
|
||||
|
@ -661,13 +661,16 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
|
|||
}
|
||||
|
||||
pr.Index = pull.Index
|
||||
if err = repo.savePatch(sess, pr.Index, patch); err != nil {
|
||||
return fmt.Errorf("SavePatch: %v", err)
|
||||
}
|
||||
|
||||
pr.BaseRepo = repo
|
||||
if err = pr.testPatch(sess); err != nil {
|
||||
return fmt.Errorf("testPatch: %v", err)
|
||||
pr.Status = PullRequestStatusChecking
|
||||
if len(patch) > 0 {
|
||||
if err = repo.savePatch(sess, pr.Index, patch); err != nil {
|
||||
return fmt.Errorf("SavePatch: %v", err)
|
||||
}
|
||||
|
||||
if err = pr.testPatch(sess); err != nil {
|
||||
return fmt.Errorf("testPatch: %v", err)
|
||||
}
|
||||
}
|
||||
// No conflict appears after test means mergeable.
|
||||
if pr.Status == PullRequestStatusChecking {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue