Skip to content

Commit 5666663

Browse files
authored
Merge pull request #7 from chainguard-dev/shellcheck-no-repeats
shellcheck_run_steps: fix loop logic
2 parents 9ed88c6 + 7de7e7d commit 5666663

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

pre_commit_hooks/shellcheck_run_steps.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ def do_shellcheck(
5050
test_pipeline = pkg["test"].get("pipeline", [])
5151
pipelines.extend(test_pipeline)
5252
name = melange_cfg["package"]["name"]
53-
all_run_files = []
53+
all_steps = []
5454
with contextlib.ExitStack() as stack:
5555
for step in pipelines:
5656
if "runs" not in step.keys():
5757
continue
58-
all_run_files.extend(
59-
[
58+
all_steps.append(
59+
(
60+
step,
6061
stack.enter_context(
6162
tempfile.NamedTemporaryFile(
6263
mode="w",
@@ -65,15 +66,15 @@ def do_shellcheck(
6566
delete_on_close=False,
6667
),
6768
),
68-
],
69+
),
6970
)
70-
for shfile in all_run_files:
71+
for step, shfile in all_steps:
7172
shfile.write(step["runs"])
7273
shfile.close()
7374
subprocess.check_call(
7475
["/usr/bin/shellcheck"]
7576
+ ["--shell=busybox", "--"]
76-
+ [os.path.basename(f.name) for f in all_run_files],
77+
+ [os.path.basename(f.name) for _, f in all_steps],
7778
cwd=os.getcwd(),
7879
)
7980

0 commit comments

Comments
 (0)