Skip to content

Commit

Permalink
working dbwebb test check if need pull
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArne committed Jun 26, 2023
1 parent 5e74fa6 commit 0068491
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions .dbwebb/test/functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,28 @@ execute_with_timeout () {
# Check if git local is behind remote
#
check_if_need_pull () {
if ! git diff --quiet remotes/origin/HEAD; then
# Difference found
return 1
fi

LOCAL_REVSPEC=HEAD
BRANCH=$(git rev-parse --abbrev-ref ${LOCAL_REVSPEC})

REMOTE_NAME=$(git config branch.${BRANCH}.remote)


REMOTE_REVSPEC=remotes/${REMOTE_NAME}/${BRANCH}

if ! git fetch ${REMOTE_NAME}
then
echo "git fetch ${REMOTE_NAME} failed"
exit 1
fi

LOCAL_SHA1=$(git rev-parse ${LOCAL_REVSPEC})
REMOTE_SHA1=$(git rev-parse ${REMOTE_REVSPEC})
BASE_SHA1=$(git merge-base ${LOCAL_REVSPEC} ${REMOTE_REVSPEC})

if [ ${LOCAL_SHA1} = ${BASE_SHA1} ]; then
# Found change in remote
return 0
fi
return 1
}

0 comments on commit 0068491

Please sign in to comment.