Skip to content

Commit 2f705fa

Browse files
committed
pants: add shfmt to format packaging scripts
disable it for all other scripts that would be reformatted. Someone can reenable it and run it on files later.
1 parent a99117f commit 2f705fa

File tree

21 files changed

+55
-3
lines changed

21 files changed

+55
-3
lines changed

BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ file(
8888

8989
shell_sources(
9090
name="root",
91+
skip_shfmt=True,
9192
)
9293

9394
file(

contrib/core/actions/send_mail/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ st2_shell_sources_and_resources(
22
name="send_mail",
33
sources=["send_mail"],
44
skip_shellcheck=True,
5+
skip_shfmt=True,
56
)

contrib/examples/actions/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ python_sources()
33
shell_sources(
44
name="shell",
55
skip_shellcheck=True,
6+
overrides={
7+
"print_to_stdout_and_stderr.sh": dict(skip_shfmt=True),
8+
}
69
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
shell_sources()
1+
shell_sources(skip_shfmt=True)

contrib/examples/actions/bash_random/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
shell_sources(
2+
skip_shfmt=True,
23
overrides={
34
"random2.sh": dict(skip_shellcheck=True),
45
},

contrib/linux/actions/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ python_sources()
33
shell_sources(
44
name="shell",
55
skip_shellcheck=True,
6+
skip_shfmt=True,
67
)

pants-plugins/macros.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def st2_shell_sources_and_resources(**kwargs):
181181
shell_sources(**kwargs) # noqa: F821
182182

183183
kwargs.pop("skip_shellcheck", None)
184+
kwargs.pop("skip_shfmt", None)
184185

185186
kwargs["name"] += "_resources"
186187
resources(**kwargs) # noqa: F821

pants.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ backend_packages = [
2626
# shell
2727
"pants.backend.shell",
2828
"pants.backend.shell.lint.shellcheck",
29+
"pants.backend.shell.lint.shfmt",
2930

3031
# packaging
3132
"pants.backend.experimental.makeself",
@@ -236,6 +237,15 @@ config = "@lint-configs/regex-lint.yaml"
236237
[setuptools]
237238
install_from_resolve = "st2"
238239

240+
[shfmt]
241+
args = [
242+
# https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd#printer-flags
243+
"--indent",
244+
"4", # default is 0 (use tabs)
245+
"--case-indent",
246+
"--simplify",
247+
]
248+
239249
[test]
240250
extra_env_vars = [
241251
# Use this so that the test system does not require the stanley user.

scripts/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ python_sources()
22

33
shell_sources(
44
name="shell",
5+
skip_shfmt=True,
56
)

scripts/ci/BUILD

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
shell_sources()
1+
shell_sources(
2+
overrides={
3+
(
4+
"add-itest-user-key.sh",
5+
"permissions-workaround.sh",
6+
"run-nightly-make-task-if-exists.sh",
7+
"submit-codecov-coverage.sh",
8+
"time-command.sh",
9+
): dict(skip_shfmt=True),
10+
},
11+
)

0 commit comments

Comments
 (0)