Skip to content

Commit 3563cc0

Browse files
committed
Document functions
1 parent b6f1d2c commit 3563cc0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

captain-hook.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@ debug() {
3131
fi
3232
}
3333

34+
# Return the sorted list of files comprising a git-hook pipeline.
3435
_getPipeline() {
3536
searchDir=$1; shift
3637
find "${searchDir}" \
3738
-regex ".*/[0-9]\{3\}+\{0,1\}.*" \
3839
| sort
3940
}
4041

42+
# Test if the supplied script is classified as a "ensured" script.
4143
_ensuredScript() {
4244
[ -z "$(echo "${script}" | sed -ne '/[0-9]\{3\}+/p')" ]
4345
}
4446

47+
# Given the existing exit-code ($1) and the exit-code of the last
48+
# script that ran ($2), return the new exit-code for this pipeline.
4549
_updateRc() {
4650
if [[ $1 -eq 0 ]]; then
4751
echo "$2"
@@ -50,11 +54,17 @@ _updateRc() {
5054
fi
5155
}
5256

57+
# Test if this pipeline is in short-circuit mode, given the current
58+
# pipeline's exit-code.
5359
_shortCircuit() {
5460
local -r rc=$1; shift
5561
[ "${rc}" -le 0 ]
5662
}
5763

64+
# Determine the exit code for the entire pipeline.
65+
#
66+
# Note: this function should be called at the end of a pipeline's
67+
# execution.
5868
_determineExitCode() {
5969
local -r rc=$1; shift
6070
# negative exit codes indicate a short-circuit without failure
@@ -65,6 +75,8 @@ _determineExitCode() {
6575
fi
6676
}
6777

78+
# This method is called by captain-hook. It will run the user's
79+
# defined git-hook pipeline when a client-side hook is invoked by git.
6880
runHook() {
6981
local -r hook=$1; shift
7082
local rc=0

0 commit comments

Comments
 (0)