Skip to content

Commit

Permalink
remove magic no 7 and introduc a variable MAX_ALLOWED_REVISIONS
Browse files Browse the repository at this point in the history
Signed-off-by: Mangaal <[email protected]>
  • Loading branch information
Mangaal committed Mar 15, 2024
1 parent 5ffcb73 commit f9e33af
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2462,6 +2462,7 @@ func printApplicationHistoryIds(revHistory []argoappv1.RevisionHistory) {

// Print a history table for an application.
func printApplicationHistoryTable(revHistory []argoappv1.RevisionHistory) {
MAX_ALLOWED_REVISIONS := 7
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
type history struct {
id int64
Expand All @@ -2474,8 +2475,8 @@ func printApplicationHistoryTable(revHistory []argoappv1.RevisionHistory) {
if depInfo.Sources != nil {
for i, sourceInfo := range depInfo.Sources {
rev := sourceInfo.TargetRevision
if len(depInfo.Revisions) == len(depInfo.Sources) && len(depInfo.Revisions[i]) >= 7 {
rev = fmt.Sprintf("%s (%s)", rev, depInfo.Revisions[i][0:7])
if len(depInfo.Revisions) == len(depInfo.Sources) && len(depInfo.Revisions[i]) >= MAX_ALLOWED_REVISIONS {
rev = fmt.Sprintf("%s (%s)", rev, depInfo.Revisions[i][0:MAX_ALLOWED_REVISIONS])
}
varHistory[sourceInfo.RepoURL] = append(varHistory[sourceInfo.RepoURL], history{
id: depInfo.ID,
Expand All @@ -2485,8 +2486,8 @@ func printApplicationHistoryTable(revHistory []argoappv1.RevisionHistory) {
}
} else {
rev := depInfo.Source.TargetRevision
if len(depInfo.Revision) >= 7 {
rev = fmt.Sprintf("%s (%s)", rev, depInfo.Revision[0:7])
if len(depInfo.Revision) >= MAX_ALLOWED_REVISIONS {
rev = fmt.Sprintf("%s (%s)", rev, depInfo.Revision[0:MAX_ALLOWED_REVISIONS])
}
varHistory[depInfo.Source.RepoURL] = append(varHistory[depInfo.Source.RepoURL], history{
id: depInfo.ID,
Expand Down

0 comments on commit f9e33af

Please sign in to comment.