mirror of
https://github.com/harness/drone.git
synced 2025-05-16 17:09:58 +08:00
backend change to remove rename commit from old file
This commit is contained in:
parent
993d653b8e
commit
df29038e40
@ -194,12 +194,27 @@ func (g Adapter) ListCommits(ctx context.Context,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
return commits, renameDetailsList, nil
|
cleanedUpCommits := cleanupCommitsForRename(commits, renameDetailsList)
|
||||||
|
return cleanedUpCommits, renameDetailsList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return commits, nil, 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(
|
func getRenameDetails(
|
||||||
giteaRepo *gitea.Repository,
|
giteaRepo *gitea.Repository,
|
||||||
commits []types.Commit,
|
commits []types.Commit,
|
||||||
|
Loading…
Reference in New Issue
Block a user