@@ -10,13 +10,14 @@ import (
1010func GetSyncStartTime (app * v1alpha1.Application , defaultStartTime time.Time ) time.Time {
1111 startTime := metav1 .NewTime (defaultStartTime )
1212 gitHash := app .Status .Sync .Revision
13- if app .Status .OperationState != nil {
13+ if app .Status .OperationState != nil &&
14+ app .Status .OperationState .Operation .Sync != nil &&
15+ app .Status .OperationState .Operation .Sync .Revision == gitHash {
1416 startTime = app .Status .OperationState .StartedAt
15- } else if app .Status .History != nil {
16- for _ , history := range app .Status .History {
17- if history .Revision == gitHash {
18- startTime = * history .DeployStartedAt
19- }
17+ } else if len (app .Status .History ) != 0 {
18+ if app .Status .History .LastRevisionHistory ().Revision == gitHash &&
19+ app .Status .History .LastRevisionHistory ().DeployStartedAt != nil {
20+ startTime = * app .Status .History .LastRevisionHistory ().DeployStartedAt
2021 }
2122 }
2223 return startTime .Time
@@ -26,7 +27,10 @@ func GetSyncStartTime(app *v1alpha1.Application, defaultStartTime time.Time) tim
2627func GetSyncFinishTime (app * v1alpha1.Application , defaultEndTime time.Time ) time.Time {
2728 finishTime := metav1 .NewTime (defaultEndTime )
2829 gitHash := app .Status .Sync .Revision
29- if app .Status .OperationState != nil && app .Status .OperationState .FinishedAt != nil {
30+ if app .Status .OperationState != nil &&
31+ app .Status .OperationState .Operation .Sync != nil &&
32+ app .Status .OperationState .Operation .Sync .Revision == gitHash &&
33+ app .Status .OperationState .FinishedAt != nil {
3034 finishTime = * app .Status .OperationState .FinishedAt
3135 } else if app .Status .History != nil {
3236 for _ , history := range app .Status .History {
0 commit comments