Skip to content

Commit

Permalink
Add fallback for default.
Browse files Browse the repository at this point in the history
  • Loading branch information
thefrosty committed Aug 5, 2022
1 parent e5c53f7 commit e77b3c2
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions bin/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,27 @@ set -e

# Default values of arguments
# https://stackoverflow.com/a/44750379/558561 -- get the default git branch name
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') || echo "develop"
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
TEST_VERSION="7.4"
OTHER_ARGUMENTS=()

# Loop through arguments and process them
# @ref https://pretzelhands.com/posts/command-line-flags/
for arg in "$@"
do
case $arg in
--default-branch)
DEFAULT_BRANCH="$2"
shift 2 # Remove name and value
;;
--test-version)
TEST_VERSION="$2"
shift 2 # Remove name and value
;;
*)
OTHER_ARGUMENTS+=("$1")
shift # Remove generic argument from processing
;;
esac
for arg in "$@"; do
case $arg in
--default-branch)
DEFAULT_BRANCH="$2"
shift 2 # Remove name and value
;;
--test-version)
TEST_VERSION="$2"
shift 2 # Remove name and value
;;
*)
OTHER_ARGUMENTS+=("$1")
shift # Remove generic argument from processing
;;
esac
done

# Based off: https://gist.github.com/Hounddog/3891872
Expand All @@ -42,4 +41,4 @@ else
exit 1
fi

commitFiles=$(git diff --name-only "$(git merge-base ${DEFAULT_BRANCH} ${against})")
commitFiles=$(git diff --name-only "$(git merge-base ${DEFAULT_BRANCH:-develop} ${against})")

0 comments on commit e77b3c2

Please sign in to comment.