From 0323122fd79f42296470bdc02dee57a5ef8e72c9 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 15 Jun 2019 22:22:26 +0800 Subject: [PATCH] fix duplicated file on pull request conflicted files (#7211) --- models/pull.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/models/pull.go b/models/pull.go index 7a168181e25b..e5d421e6baba 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 {