1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-25 10:04:27 +00:00

Fix file rename/copy not supported by indexer (#9967)

This commit is contained in:
guillep2k 2020-01-24 20:25:00 -03:00 committed by techknowlogick
parent ef8f6d99f1
commit 16fc15ae6a

View File

@ -116,7 +116,12 @@ func nonGenesisChanges(repo *models.Repository, revision string) (*repoChanges,
if len(line) == 0 { if len(line) == 0 {
continue continue
} }
filename := strings.TrimSpace(line[1:]) fields := strings.Split(line, "\t")
if len(fields) < 2 {
log.Warn("Unparseable output for diff --name-status: `%s`)", line)
continue
}
filename := fields[1]
if len(filename) == 0 { if len(filename) == 0 {
continue continue
} else if filename[0] == '"' { } else if filename[0] == '"' {
@ -126,11 +131,31 @@ func nonGenesisChanges(repo *models.Repository, revision string) (*repoChanges,
} }
} }
switch status := line[0]; status { switch status := fields[0][0]; status {
case 'M', 'A': case 'M', 'A':
updatedFilenames = append(updatedFilenames, filename) updatedFilenames = append(updatedFilenames, filename)
case 'D': case 'D':
changes.RemovedFilenames = append(changes.RemovedFilenames, filename) changes.RemovedFilenames = append(changes.RemovedFilenames, filename)
case 'R', 'C':
if len(fields) < 3 {
log.Warn("Unparseable output for diff --name-status: `%s`)", line)
continue
}
dest := fields[2]
if len(dest) == 0 {
log.Warn("Unparseable output for diff --name-status: `%s`)", line)
continue
}
if dest[0] == '"' {
dest, err = strconv.Unquote(dest)
if err != nil {
return nil, err
}
}
if status == 'R' {
changes.RemovedFilenames = append(changes.RemovedFilenames, filename)
}
updatedFilenames = append(updatedFilenames, dest)
default: default:
log.Warn("Unrecognized status: %c (line=%s)", status, line) log.Warn("Unrecognized status: %c (line=%s)", status, line)
} }