| 247 | } |
| 248 | |
| 249 | func (c *commandRepositoryUpgrade) runPhase(act func(context.Context, repo.DirectRepositoryWriter) error) func(context.Context, repo.DirectRepositoryWriter) error { |
| 250 | return func(ctx context.Context, rep repo.DirectRepositoryWriter) error { |
| 251 | if c.skip { |
| 252 | return nil |
| 253 | } |
| 254 | |
| 255 | err := act(ctx, rep) |
| 256 | if err != nil { |
| 257 | // Explicitly skip all stages on error because tests do not |
| 258 | // skip/exit on error. Tests override os.Exit() that prevents |
| 259 | // running rest of the phases until we set the skip flag here. |
| 260 | // This flag is designed for testability and also to support |
| 261 | // rollback. |
| 262 | c.skip = true |
| 263 | } |
| 264 | |
| 265 | return err |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | func (c *commandRepositoryUpgrade) ignoreErrorOnAlwaysCommit(act func(context.Context, repo.DirectRepositoryWriter) error) func(context.Context, repo.DirectRepositoryWriter) error { |
| 270 | return func(ctx context.Context, rep repo.DirectRepositoryWriter) error { |