diff --git a/tools/bump/flake.go b/tools/bump/flake.go index 5297ce39..04b63fba 100644 --- a/tools/bump/flake.go +++ b/tools/bump/flake.go @@ -88,6 +88,15 @@ func applyFlake(ctx context.Context, r *repo) (change, error) { return change{Empty: true}, nil } + // The lock decides which prettier, gofumpt and nixfmt the tree is judged + // by, so moving it can leave files no bump touched failing the formatting + // check. Reformatting belongs in this commit rather than a later one: the + // gate below judges this tree, and the cause is this change. + err = runFormatters(ctx, r) + if err != nil { + return change{}, err + } + detail := moved if tools, err := toolVersions(ctx, r); err == nil { //nolint:noinlineerr diff --git a/tools/bump/generate.go b/tools/bump/generate.go index a8bcb61f..55217a46 100644 --- a/tools/bump/generate.go +++ b/tools/bump/generate.go @@ -140,13 +140,7 @@ func gateGenerate(ctx context.Context, r *repo) error { // The first hook pass is expected to fail, because a hook that rewrites a file // reports failure. The second pass is the real verdict. func applyFormat(ctx context.Context, r *repo) (change, error) { - if _, err := r.nixRun(ctx, "make", "fmt"); err != nil { //nolint:noinlineerr - return change{}, err - } - - _, _ = r.nixRun(ctx, "prek", "run", "--all-files") - - if _, err := r.nixRun(ctx, "prek", "run", "--all-files"); err != nil { //nolint:noinlineerr + if err := runFormatters(ctx, r); err != nil { //nolint:noinlineerr return change{}, err } @@ -164,3 +158,18 @@ func applyFormat(ctx context.Context, r *repo) (change, error) { Detail: touched, }, nil } + +// runFormatters brings the tree up to whatever the current toolchain considers +// formatted. The first hook pass is expected to fail, because a hook that +// rewrites a file reports failure; the second pass is the verdict. +func runFormatters(ctx context.Context, r *repo) error { + if _, err := r.nixRun(ctx, "make", "fmt"); err != nil { //nolint:noinlineerr + return err + } + + _, _ = r.nixRun(ctx, "prek", "run", "--all-files") + + _, err := r.nixRun(ctx, "prek", "run", "--all-files") + + return err +}