From fefa14e1356da04a5056a5b5816583c91aaccaa2 Mon Sep 17 00:00:00 2001 From: Guillaume MOCQUET Date: Thu, 17 Jun 2021 14:35:32 +0200 Subject: [PATCH] feat(git-branch-linearity): add support to main or master target branch v2 --- git-branch-linearity.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-branch-linearity.sh b/git-branch-linearity.sh index 9a7164f..c8b1748 100755 --- a/git-branch-linearity.sh +++ b/git-branch-linearity.sh @@ -1,10 +1,10 @@ #!/bin/sh -if [ "$(git branch --list main)" ]; then TARGET_BRANCH="main"; else TARGET_BRANCH="master"; fi - +git fetch origin main:refs/remotes/origin/main 2> /dev/null +if [ $? -eq 0 ]; then TARGET_BRANCH="main"; else TARGET_BRANCH="master"; fi echo "Target branch: $TARGET_BRANCH" -out=$(git log origin/${TARGET_BRANCH}..HEAD --merges --oneline) +out=$(git log origin/${TARGET_BRANCH}..HEAD --merges --oneline) exit_status=$? if [ -n "$out" ] then @@ -13,7 +13,7 @@ then echo "\nMerge commit(s):" >&2 echo "$out" >&2 # Disclaimer: current version of the check doesn't work well with release branches -exit_status=1 + exit_status=1 fi exit ${exit_status}