diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2020-01-24 20:26:49 -0300 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2020-01-24 18:26:49 -0500 |
commit | ee26f042c421d90cbd3f852427de8b98f1cc71a7 (patch) | |
tree | 47c71e0ca4e750ef8b02d2e25bc4ab8d37a29327 /modules/indexer | |
parent | 700611cc18e58343d9d67980263b246bcacb6171 (diff) | |
download | gitea-ee26f042c421d90cbd3f852427de8b98f1cc71a7.tar.gz gitea-ee26f042c421d90cbd3f852427de8b98f1cc71a7.zip |
Fix file rename/copy not supported by indexer (#9965)
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'modules/indexer')
-rw-r--r-- | modules/indexer/code/git.go | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/modules/indexer/code/git.go b/modules/indexer/code/git.go index bfa7d20438..114d5a9e6d 100644 --- a/modules/indexer/code/git.go +++ b/modules/indexer/code/git.go @@ -116,7 +116,12 @@ func nonGenesisChanges(repo *models.Repository, revision string) (*repoChanges, if len(line) == 0 { 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 { continue } 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': updatedFilenames = append(updatedFilenames, filename) case 'D': 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: log.Warn("Unrecognized status: %c (line=%s)", status, line) } |