summaryrefslogtreecommitdiffstats
path: root/models/pull.go
diff options
context:
space:
mode:
authorMura Li <typeless@users.noreply.github.com>2019-08-21 01:43:00 +0800
committertechknowlogick <techknowlogick@gitea.io>2019-08-20 13:43:00 -0400
commit3ac45e3cb58c81941618be69d40a0e2ea39080bf (patch)
tree1bbff0d3cd0cde399ddba8625d03711e96535f1d /models/pull.go
parent31f5713a1f2f6267a66526eacf502e3cce73f737 (diff)
downloadgitea-3ac45e3cb58c81941618be69d40a0e2ea39080bf.tar.gz
gitea-3ac45e3cb58c81941618be69d40a0e2ea39080bf.zip
Fix pull creation with empty changes (#7920)
* Logs the stderr of git-apply * Add an integration test * Skip testPatch when patch is empty
Diffstat (limited to 'models/pull.go')
-rw-r--r--models/pull.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/models/pull.go b/models/pull.go
index 8728fa11cb..b1ceca472c 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -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 {