From a27da47aa59278e66d05aa918d580fa4c2fb4575 Mon Sep 17 00:00:00 2001 From: carlfriedrich Date: Sat, 6 Sep 2025 13:25:23 +0200 Subject: [PATCH] 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. --- bin/git-forgit | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/git-forgit b/bin/git-forgit index c2567e1..024988d 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -1270,4 +1270,10 @@ PRIVATE_COMMANDS=( "pager" ) +# Check if the script is being sourced. This is necessary for unit tests where +# we do not want to execute the main function. +if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then + return 0 +fi + main "${@}"