Packaging: Add shfmt to format deb maintainer scripts / rpm scriptlets#6317
Merged
cognifloyd merged 4 commits intomasterfrom Mar 18, 2025
Merged
Packaging: Add shfmt to format deb maintainer scripts / rpm scriptlets#6317cognifloyd merged 4 commits intomasterfrom
cognifloyd merged 4 commits intomasterfrom
Conversation
disable it for all other scripts that would be reformatted. Someone can reenable it and run it on files later.
nzlosh
approved these changes
Mar 16, 2025
Contributor
|
Good initiative to formatting shell code. There are shell script that are all over the place at the moment. 👍 |
rush-skills
approved these changes
Mar 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is working towards doing packaging via pantsbuild. Eventually, I hope to archive and stop using st2-packages.git.
The inconsistent formatting makes it harder to compare deb vs rpm scripts. At first I reformatted manually, but that will get lost quickly as we all make improvements. So, I added
shfmtto format deb maintainer scripts / rpm scriptlets. To enable it I added the shfmt backend to[GLOBAL].backend_packagesinpants.toml.st2/pants.toml
Line 29 in 08fd2ba
I want to keep this PR focused on packaging, so I added
skip_shfmt=Trueto all the BUILD metadata for shell scripts that would be reformatted (other thanpackaging/{rpm,deb}/scripts/*.sh. Someone else can remove thoseskip_shfmtparameters to enable formatting other shell scripts.shfmtdoes not have a lot of options for formatting. I changed 2 of them:st2/pants.toml
Lines 240 to 245 in 08fd2ba
Most of our shell scripts use spaces instead of tabs for indentation. Some have 2 spaces while others have 4. I went with 4 for now (
--indent=4). We can change it later if that proves annoying. I just want consistency.All of our shell scripts indent case statements (though the indent size is inconsistent), so I enabled the
--case-indentoption as well. The formatting is a little different than I normally use, but it is at least consistent.