This script is called updatePR
.
Usage:
gh pr checkout 1234
# make some changes
updatePR 1234
You will be prompted to confirm whether you want to push commits to the remote branch from which the PR originated. This requires that you have write access to that destination.
Add the following to your .zshrc
or .bashrc
.
updatePR () {
destination=$(gh pr view $1 --json headRepositoryOwner,headRepository,headRefName | jq -r '"git@github.com:" + .headRepositoryOwner.login + "/" + .headRepository.name + ".git HEAD:" + .headRefName')
echo "Pushing to ${destination}"
read confirm"?Are you sure? Type [y] to continue: "
echo
if [[ $confirm =~ ^[Yy]$ ]]
then
$(echo "git push ${destination}")
fi
}