diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-06-15 22:22:26 +0800 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-06-15 15:22:26 +0100 |
commit | 0323122fd79f42296470bdc02dee57a5ef8e72c9 (patch) | |
tree | c42ecddd5bcb37471b431dc6599cbaa2d859dacd /models/pull.go | |
parent | 94ceaf1c0c2ae0b5abcb3b62c5c903258659615c (diff) | |
download | gitea-0323122fd79f42296470bdc02dee57a5ef8e72c9.tar.gz gitea-0323122fd79f42296470bdc02dee57a5ef8e72c9.zip |
fix duplicated file on pull request conflicted files (#7211)
Diffstat (limited to 'models/pull.go')
-rw-r--r-- | models/pull.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/models/pull.go b/models/pull.go index 7a168181e2..e5d421e6ba 100644 --- a/models/pull.go +++ b/models/pull.go @@ -863,7 +863,17 @@ func (pr *PullRequest) testPatch(e Engine) (err error) { line := scanner.Text() if strings.HasPrefix(line, prefix) { - pr.ConflictedFiles = append(pr.ConflictedFiles, strings.TrimSpace(strings.Split(line[len(prefix):], ":")[0])) + var found bool + var filepath = strings.TrimSpace(strings.Split(line[len(prefix):], ":")[0]) + for _, f := range pr.ConflictedFiles { + if f == filepath { + found = true + break + } + } + if !found { + pr.ConflictedFiles = append(pr.ConflictedFiles, filepath) + } } // only list 10 conflicted files if len(pr.ConflictedFiles) >= 10 { |