@@ -67,7 +67,7 @@ func zeroToCurrent(ctx, conn context.Context, m Method, target *Target, tag *[]s
6767type empty struct {
6868}
6969
70- var BadCommitMethods map [string ]map [plumbing.Hash ]empty = make (map [string ]map [plumbing.Hash ]empty )
70+ var BadCommitList map [string ]map [string ] map [ plumbing.Hash ]empty = make (map [ string ] map [string ]map [plumbing.Hash ]empty )
7171
7272func currentToLatest (ctx , conn context.Context , m Method , target * Target , tag * []string ) error {
7373 if target .disconnected && len (target .url ) > 0 {
@@ -85,13 +85,19 @@ func currentToLatest(ctx, conn context.Context, m Method, target *Target, tag *[
8585 return fmt .Errorf ("Failed to get current commit: %v" , err )
8686 }
8787
88- if _ , ok := BadCommitMethods [m .GetKind ()]; ! ok {
89- BadCommitMethods [m .GetKind ()] = make (map [plumbing.Hash ]empty )
90- }
88+ if target .trackBadCommits {
89+ if _ , ok := BadCommitList [target .name ]; ! ok {
90+ BadCommitList [target .name ] = make (map [string ]map [plumbing.Hash ]empty )
91+ }
9192
92- if _ , ok := BadCommitMethods [m .GetKind ()][latest ]; ok {
93- klog .Infof ("No changes applied to target %s this run, %s currently at %s" , target .name , m .GetKind (), current )
94- return nil
93+ if _ , ok := BadCommitList [target .name ][m .GetKind ()]; ! ok {
94+ BadCommitList [target .name ][m .GetKind ()] = make (map [plumbing.Hash ]empty )
95+ }
96+
97+ if _ , ok := BadCommitList [target .name ][m .GetKind ()][latest ]; ok {
98+ klog .Infof ("No changes applied to target %s this run, %s currently at %s" , target .name , m .GetKind (), current )
99+ return nil
100+ }
95101 }
96102
97103 if latest != current {
@@ -108,7 +114,9 @@ func currentToLatest(ctx, conn context.Context, m Method, target *Target, tag *[
108114 // Roll back failed
109115 return fmt .Errorf ("Roll back failed, state between %s and %s: %v" , current , latest , err )
110116 }
111- BadCommitMethods [m .GetKind ()][latest ] = empty {}
117+ if target .trackBadCommits {
118+ BadCommitList [target .name ][m .GetKind ()][latest ] = empty {}
119+ }
112120 return fmt .Errorf ("Rolled back to %v: %v" , current , err )
113121 }
114122
0 commit comments