Skip to content

Commit

Permalink
[refactor] Check for a nil lastTime before use
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Mallon (Nalum) <luke@mallon.ie>
  • Loading branch information
Nalum committed Jan 11, 2022
1 parent 38570b4 commit c026e67
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions controllers/imageupdateautomation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,16 @@ func (r *ImageUpdateAutomationReconciler) Reconcile(ctx context.Context, req ctr
}

if rev, err := commitChangedManifests(tracelog, repo, tmp, signingEntity, author, message); err != nil {
if err == errNoChanges {
debuglog.Info("no changes made in working directory; no commit")
statusMessage = "no updates made"
if lastCommit, lastTime := auto.Status.LastPushCommit, auto.Status.LastPushTime; lastCommit != "" {
statusMessage = fmt.Sprintf("%s; last commit %s at %s", statusMessage, lastCommit[:7], lastTime.Format(time.RFC3339))
}
} else {
if err != errNoChanges {
return failWithError(err)
}

debuglog.Info("no changes made in working directory; no commit")
statusMessage = "no updates made"

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.
pushCtx, cancel := context.WithTimeout(ctx, origin.Spec.Timeout.Duration)
Expand Down

0 comments on commit c026e67

Please sign in to comment.