tools/bump: reformat inside the lock bump

gateFlake judges the formatting check right after the lock moves, but the
fmt area runs last, so the new toolchain's formatting had not been applied
yet and the flake area dropped itself every run.
This commit is contained in:
Kristoffer Dalby
2026-09-09 18:33:21 +00:00
parent 8d89742a21
commit f1186d8e00
2 changed files with 25 additions and 7 deletions
+9
View File
@@ -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
+16 -7
View File
@@ -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
}