Currently, when puku adds new deps (and values for other attributes) it preserves the order of any existing dependencies and adds the new ones to the end of the list (in an arbitrary order).
This adds a little friciton to development workflows as it means that any ordering that the attribute had before the changes (e.g. the order that plz format sorts them in) is unlinkely to be preserved. The user then must ensure that the ordering is preserved, and until this is done the file is in an 'incorrect' state.
Arguably, it might be preferable to just encourage users to apply plz format (on the BUILD file) immediately after each call to puku (on the go file) as this would achieve some seperation of concerns and remove any risk of the two sorting implementations drifting. It would also support users who don't use plz format and want to preserve some other ordering (although this could be solved via e.g. a config option).
However, moving this burden onto users is a suboptimal UX for most users.
It is worth noting that the current behaviour is inconsistent with other tools and therefore most user's expections (e.g. gazelle sorts new attributes, goimports applies gofmt, etc.).
I think that puku should sort the attributes. via e.g. a call to buildtools/build.SortStringList() or formatting the entire BUILD file via something equivalent to plz format.
If necessary, a config option could be added to make this behaviour optional.
If the maintainers agree that this would be a useful change I'd be happy to raise a PR once there is consensus on the desired behaviour.
Currently, when puku adds new deps (and values for other attributes) it preserves the order of any existing dependencies and adds the new ones to the end of the list (in an arbitrary order).
This adds a little friciton to development workflows as it means that any ordering that the attribute had before the changes (e.g. the order that
plz formatsorts them in) is unlinkely to be preserved. The user then must ensure that the ordering is preserved, and until this is done the file is in an 'incorrect' state.Arguably, it might be preferable to just encourage users to apply
plz format(on the BUILD file) immediately after each call topuku(on the go file) as this would achieve some seperation of concerns and remove any risk of the two sorting implementations drifting. It would also support users who don't useplz formatand want to preserve some other ordering (although this could be solved via e.g. a config option).However, moving this burden onto users is a suboptimal UX for most users.
It is worth noting that the current behaviour is inconsistent with other tools and therefore most user's expections (e.g. gazelle sorts new attributes, goimports applies gofmt, etc.).
I think that puku should sort the attributes. via e.g. a call to
buildtools/build.SortStringList()or formatting the entire BUILD file via something equivalent toplz format.If necessary, a config option could be added to make this behaviour optional.
If the maintainers agree that this would be a useful change I'd be happy to raise a PR once there is consensus on the desired behaviour.