Skip to content

Commit

Permalink
[refactor] Log LastPushCommit if of appropriate length
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Mallon (Nalum) <luke.mallon@weave.works>
  • Loading branch information
Nalum committed Jan 5, 2022
1 parent 14c4346 commit d8d1db9
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions controllers/imageupdateautomation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,8 @@ func (r *ImageUpdateAutomationReconciler) Reconcile(ctx context.Context, req ctr
debuglog.Info("no changes made in working directory; no commit")
statusMessage = "no updates made"

if auto.Status.LastPushTime != nil && auto.Status.LastPushCommit != "" {
lpcLen := len(auto.Status.LastPushCommit)
message := `%s; last commit "%s" at %s`

if lpcLen > 7 {
lpcLen = 7
message = `%s; last commit "%s..." at %s`
}

statusMessage = fmt.Sprintf(message, statusMessage, auto.Status.LastPushCommit[:lpcLen], auto.Status.LastPushTime.Format(time.RFC3339))
if auto.Status.LastPushTime != nil && len(auto.Status.LastPushCommit) >= 7 {
statusMessage = fmt.Sprintf("%s; last commit %s at %s", statusMessage, auto.Status.LastPushCommit[:7], auto.Status.LastPushTime.Format(time.RFC3339))
}
} else {
// Use the git operations timeout for the repo.
Expand Down

0 comments on commit d8d1db9

Please sign in to comment.