Skip to content

Commit ab6a63e

Browse files
committed
Chore: Do not execute any code when forgit is sourced (#464)
In order to run unit tests for individual functions we have to be able to source the script without triggering the main execution flow.
1 parent 9b3b185 commit ab6a63e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bin/git-forgit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,4 +1270,10 @@ PRIVATE_COMMANDS=(
12701270
"pager"
12711271
)
12721272

1273+
# Check if the script is being sourced. This is necessary for unit tests where
1274+
# we do not want to execute the main function.
1275+
if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then
1276+
return 0
1277+
fi
1278+
12731279
main "${@}"

0 commit comments

Comments
 (0)