diff --git a/app/api/controller/util.go b/app/api/controller/util.go index 3e24ce561..614abd7b7 100644 --- a/app/api/controller/util.go +++ b/app/api/controller/util.go @@ -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, diff --git a/app/services/webhook/types.go b/app/services/webhook/types.go index 3f2aa58ba..3a816afc6 100644 --- a/app/services/webhook/types.go +++ b/app/services/webhook/types.go @@ -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) } } diff --git a/git/adapter/commit.go b/git/adapter/commit.go index 9c65c9bc0..023b1287e 100644 --- a/git/adapter/commit.go +++ b/git/adapter/commit.go @@ -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 diff --git a/git/commit.go b/git/commit.go index 59f329332..2e3d2e149 100644 --- a/git/commit.go +++ b/git/commit.go @@ -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 diff --git a/git/mapping.go b/git/mapping.go index ccc0baa23..66df1c2b7 100644 --- a/git/mapping.go +++ b/git/mapping.go @@ -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,