mirror of https://github.com/harness/drone.git
[MISC] Fix naming inconsistencies for FileDiffStatus (#1128)
parent
16ef31bcb6
commit
a6bfe6235f
|
@ -126,7 +126,7 @@ func mapFileStats(c *git.Commit) []types.CommitFileStats {
|
|||
fileStats[i] = types.CommitFileStats{
|
||||
Path: fStat.Path,
|
||||
OldPath: fStat.OldPath,
|
||||
Status: fStat.ChangeType,
|
||||
Status: fStat.Status,
|
||||
ChangeStats: types.ChangeStats{
|
||||
Insertions: fStat.Insertions,
|
||||
Deletions: fStat.Deletions,
|
||||
|
|
|
@ -192,18 +192,18 @@ func commitInfoFrom(commit git.Commit) CommitInfo {
|
|||
|
||||
for _, stat := range commit.FileStats {
|
||||
switch {
|
||||
case stat.ChangeType == gitenum.FileDiffStatusModified:
|
||||
case stat.Status == gitenum.FileDiffStatusModified:
|
||||
modified = append(modified, stat.Path)
|
||||
case stat.ChangeType == gitenum.FileDiffStatusRenamed:
|
||||
case stat.Status == gitenum.FileDiffStatusRenamed:
|
||||
added = append(added, stat.Path)
|
||||
removed = append(removed, stat.OldPath)
|
||||
case stat.ChangeType == gitenum.FileDiffStatusDeleted:
|
||||
case stat.Status == gitenum.FileDiffStatusDeleted:
|
||||
removed = append(removed, stat.Path)
|
||||
case stat.ChangeType == gitenum.FileDiffStatusAdded || stat.ChangeType == gitenum.FileDiffStatusCopied:
|
||||
case stat.Status == gitenum.FileDiffStatusAdded || stat.Status == gitenum.FileDiffStatusCopied:
|
||||
added = append(added, stat.Path)
|
||||
case stat.ChangeType == gitenum.FileDiffStatusUndefined:
|
||||
case stat.Status == gitenum.FileDiffStatusUndefined:
|
||||
default:
|
||||
log.Warn().Msgf("unknown change type %q for path %q", stat.ChangeType, stat.Path)
|
||||
log.Warn().Msgf("unknown status %q for path %q", stat.Status, stat.Path)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ func getCommitFileStats(
|
|||
fileStats[i] = types.CommitFileStats{
|
||||
Path: changeInfoTypes[path].Path,
|
||||
OldPath: changeInfoTypes[path].OldPath,
|
||||
Status: changeInfoTypes[path].ChangeType,
|
||||
Status: changeInfoTypes[path].Status,
|
||||
Insertions: info.Insertions,
|
||||
Deletions: info.Deletions,
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ func giteaGetRenameDetails(
|
|||
}
|
||||
|
||||
for _, c := range changeInfos {
|
||||
if c.ChangeType == enum.FileDiffStatusRenamed && (c.OldPath == path || c.Path == path) {
|
||||
if c.Status == enum.FileDiffStatusRenamed && (c.OldPath == path || c.Path == path) {
|
||||
return &types.PathRenameDetails{
|
||||
OldPath: c.OldPath,
|
||||
Path: c.Path,
|
||||
|
@ -312,8 +312,8 @@ func gitLogNameStatus(giteaRepo *gitea.Repository, ref string) ([]string, error)
|
|||
cmd := command.New("log",
|
||||
command.WithFlag("--name-status"),
|
||||
command.WithFlag("--format="),
|
||||
command.WithArg(ref),
|
||||
command.WithFlag("--max-count=1"),
|
||||
command.WithArg(ref),
|
||||
)
|
||||
output := &bytes.Buffer{}
|
||||
err := cmd.Run(giteaRepo.Ctx, command.WithDir(giteaRepo.Path), command.WithStdout(output))
|
||||
|
@ -367,7 +367,7 @@ func getChangeInfoTypes(
|
|||
c.Path = lineParts[1]
|
||||
}
|
||||
|
||||
c.ChangeType = convertChangeType(ctx, line)
|
||||
c.Status = convertFileDiffStatus(ctx, line)
|
||||
|
||||
changeInfoTypes[c.Path] = c
|
||||
}
|
||||
|
@ -425,16 +425,16 @@ func getChangeInfoChanges(
|
|||
}
|
||||
|
||||
type changeInfoType struct {
|
||||
ChangeType enum.FileDiffStatus
|
||||
OldPath string // populated only in case of renames
|
||||
Path string
|
||||
Status enum.FileDiffStatus
|
||||
OldPath string // populated only in case of renames
|
||||
Path string
|
||||
}
|
||||
type changeInfoChange struct {
|
||||
Insertions int64
|
||||
Deletions int64
|
||||
}
|
||||
|
||||
func convertChangeType(ctx context.Context, c string) enum.FileDiffStatus {
|
||||
func convertFileDiffStatus(ctx context.Context, c string) enum.FileDiffStatus {
|
||||
switch {
|
||||
case strings.HasPrefix(c, "A"):
|
||||
return enum.FileDiffStatusAdded
|
||||
|
|
|
@ -127,7 +127,7 @@ type ListCommitsOutput struct {
|
|||
}
|
||||
|
||||
type CommitFileStats struct {
|
||||
ChangeType enum.FileDiffStatus
|
||||
Status enum.FileDiffStatus
|
||||
Path string
|
||||
OldPath string // populated only in case of renames
|
||||
Insertions int64
|
||||
|
|
|
@ -72,7 +72,7 @@ func mapFileStats(typeStats []types.CommitFileStats) []CommitFileStats {
|
|||
|
||||
for i, tStat := range typeStats {
|
||||
stats[i] = CommitFileStats{
|
||||
ChangeType: tStat.Status,
|
||||
Status: tStat.Status,
|
||||
Path: tStat.Path,
|
||||
OldPath: tStat.OldPath,
|
||||
Insertions: tStat.Insertions,
|
||||
|
|
Loading…
Reference in New Issue