1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-26 09:09:36 -05:00

fix duplicated file on pull request conflicted files (#7211)

This commit is contained in:
Lunny Xiao 2019-06-15 22:22:26 +08:00 committed by zeripath
parent 94ceaf1c0c
commit 0323122fd7

View file

@ -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 {