backend change to remove rename commit from old file

This commit is contained in:
Abhinav Singh 2023-06-05 22:33:35 -07:00
parent 993d653b8e
commit df29038e40

View File

@ -194,12 +194,27 @@ func (g Adapter) ListCommits(ctx context.Context,
if err != nil {
return nil, nil, err
}
return commits, renameDetailsList, nil
cleanedUpCommits := cleanupCommitsForRename(commits, renameDetailsList)
return cleanedUpCommits, renameDetailsList, nil
}
return commits, nil, nil
}
// In case of rename of a file, same commit will be listed twice - Once in old file and second time in new file.
// Hence, we are making it a pattern to only list it as part of new file and not as part of old file.
func cleanupCommitsForRename(commits []types.Commit, renameDetails []types.PathRenameDetails) []types.Commit {
if len(commits) == 0 {
return commits
}
for _, renameDetail := range renameDetails {
if commits[0].SHA == renameDetail.CommitSHABefore {
return commits[1:]
}
}
return commits
}
func getRenameDetails(
giteaRepo *gitea.Repository,
commits []types.Commit,