mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-03 05:13:36 +09:00
tools/bump: reformat after the toolchain moves
nixpkgs decides which prettier and gofumpt format the tree. A lock bump to prettier 3.9.6 reformatted CHANGELOG.md, which no area had touched, and the formatting check failed on a file the bot never edited.
This commit is contained in:
+11
-1
@@ -82,13 +82,23 @@ func allAreas() []area {
|
|||||||
areas = append(areas, imageAreas()...)
|
areas = append(areas, imageAreas()...)
|
||||||
areas = append(areas, actionAreas()...)
|
areas = append(areas, actionAreas()...)
|
||||||
|
|
||||||
return append(areas, area{
|
areas = append(areas, area{
|
||||||
Name: "generate",
|
Name: "generate",
|
||||||
Needs: []string{"gomod", "tools:oapi-codegen"},
|
Needs: []string{"gomod", "tools:oapi-codegen"},
|
||||||
Apply: applyGenerate,
|
Apply: applyGenerate,
|
||||||
Gate: gateGenerate,
|
Gate: gateGenerate,
|
||||||
Message: func(change) string { return "all: regenerate generated files" },
|
Message: func(change) string { return "all: regenerate generated files" },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Last, so it also covers whatever the generators emitted. nixpkgs decides
|
||||||
|
// which prettier and gofumpt the tree is formatted with, so a lock bump can
|
||||||
|
// reformat files no other area went near.
|
||||||
|
return append(areas, area{
|
||||||
|
Name: "fmt",
|
||||||
|
Needs: []string{"flake"},
|
||||||
|
Apply: applyFormat,
|
||||||
|
Message: func(change) string { return "all: apply the formatters from the new toolchain" },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// runAreas applies each area in order, committing the ones that hold and
|
// runAreas applies each area in order, committing the ones that hold and
|
||||||
|
|||||||
@@ -129,3 +129,27 @@ func gateGenerate(ctx context.Context, r *repo) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// applyFormat re-runs the repository formatters. A toolchain bump can change
|
||||||
|
// what "formatted" means: a newer prettier out of nixpkgs reformats files no
|
||||||
|
// bump touched, and the formatting check then fails on a tree the bot never
|
||||||
|
// edited. Running last means it also tidies whatever the generators emitted.
|
||||||
|
func applyFormat(ctx context.Context, r *repo) (change, error) {
|
||||||
|
if _, err := r.nixRun(ctx, "make", "fmt"); err != nil { //nolint:noinlineerr
|
||||||
|
return change{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
touched, err := changedFiles(ctx, r)
|
||||||
|
if err != nil {
|
||||||
|
return change{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(touched) == 0 {
|
||||||
|
return change{Empty: true}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return change{
|
||||||
|
Summary: fmt.Sprintf("%d file(s) reformatted", len(touched)),
|
||||||
|
Detail: touched,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user