Skip to content

Instantly share code, notes, and snippets.

@namikingsoft
Last active December 16, 2020 20:50
Show Gist options
  • Save namikingsoft/ff8571ac3aed419c9bd69f57eb7d5c9e to your computer and use it in GitHub Desktop.
Save namikingsoft/ff8571ac3aed419c9bd69f57eb7d5c9e to your computer and use it in GitHub Desktop.
Fetch base sha1 from github pull request number
GITHUB_PR_NUMBER=1234
base_branch_sha1() {
MERGED_BRANCH="pull/${GITHUB_PR_NUMBER}/merge"
git fetch origin "${MERGED_BRANCH}:${MERGED_BRANCH}" > /dev/null
git log "${MERGED_BRANCH}" --oneline | head -n1 | sed -e 's/^.* into //'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment