Created
March 21, 2024 20:14
-
-
Save dpino/e7892470bd5dda746fa612ff007cd496 to your computer and use it in GitHub Desktop.
current_branch_equals_remote.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
[email protected]:microsoft/playwright.git | |
BRANCH=release-1.41 | |
current_branch_equals_remote() { | |
git branch -vv | |
local current_branch=$(git rev-parse --abbrev-ref HEAD) | |
if [[ $(git log -1 --pretty="%h" ${current_branch}) == $(git log -1 --pretty="%h" origin/${current_branch}) ]]; then | |
echo "Current branch equals remote branch" | |
else | |
echo "Current branch NOT equals remote branch" | |
fi | |
} | |
git clone -b ${BRANCH} ${REPO} | |
cd playwright | |
echo "--" | |
current_branch_equals_remote | |
git fetch -f ${REPO} HEAD &>/dev/null | |
git reset --hard FETCH_HEAD &>/dev/null | |
echo "--" | |
current_branch_equals_remote | |
# Result: | |
# -- | |
# * release-1.41 a4096676a [origin/release-1.41] chore: mark 1.41.2 (#29293) | |
# Current branch equals remote branch | |
# -- | |
# * release-1.41 ef57489cf [origin/release-1.41: ahead 366, behind 15] test: iframe is covered by service workers (#30042) | |
# Current branch NOT equals remote branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment