Skip to content

fix(hooks): incorrect found count/skipped output in mixed exec/non-exec batches #2551

Open
joshtrichards wants to merge 1 commit intomasterfrom
jtr/fix-hooks-nonexec-counter-bug
Open

fix(hooks): incorrect found count/skipped output in mixed exec/non-exec batches #2551
joshtrichards wants to merge 1 commit intomasterfrom
jtr/fix-hooks-nonexec-counter-bug

Conversation

@joshtrichards
Copy link
Member

The found variable is incorrectly decremented for non-executable scripts, which leads to misleading output when a hook folder contains an executable + a non-executable script (output will indicate the folder was fully scripted).

Place two scripts in before-starting hook folder: scriptA.sh and scriptB.sh.
Make sure scriptA.sh is properly executable.
Make sure scriptB.sh is not executable.

before:

=> Searching for hook scripts (*.sh) to run, located in the folder "/docker-entrypoint-hooks.d/before-starting"
==> Running the script (cwd: /var/www/html): "/docker-entrypoint-hooks.d/before-starting/scriptA.sh"
hello from scriptA.sh
==> Finished executing the script: "/docker-entrypoint-hooks.d/before-starting/scriptA.sh"
==> The script "/docker-entrypoint-hooks.d/before-starting/scriptB.sh was skipped, because it lacks the executable flag
==> Skipped: the "before-starting" folder does not contain any valid scripts

^^^last line

after:

=> Searching for hook scripts (*.sh) to run, located in the folder "/docker-entrypoint-hooks.d/before-starting"
==> Running the script (cwd: /var/www/html): "/docker-entrypoint-hooks.d/before-starting/scriptA.sh.sh"
hello from scriptA.sh
==> Finished executing the script: "/docker-entrypoint-hooks.d/before-starting/scriptA.sh"
==> The script "/docker-entrypoint-hooks.d/before-starting/scriptB.sh" was skipped, because it lacks the executable flag
=> Completed executing scripts in the "before-starting" folder

The `found` variable is incorrectly decremented for non-executable scripts, which leads to misleading output when a hook folder contains an executable + a non-executable script (output will indicate the folder was fully scripted).

Signed-off-by: Josh <josh.t.richards@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant