Archived
1
0

refactor: update script command to get git branch

This commit is contained in:
Joe Previte
2021-03-24 16:35:55 -07:00
parent a1dca6da29
commit 299e17e6d9
3 changed files with 17 additions and 11 deletions

View File

@ -81,13 +81,14 @@ main() {
# Push branch to remote if not already pushed
# If we don't do this, the opening a draft PR step won't work
# because it will stop and ask where you want to push the branch
CURRENT_BRANCH=$(git branch --show-current)
if [[ -z $(git ls-remote --heads origin "$CURRENT_BRANCH") ]]; then
CURRENT_BRANCH=$(git branch | grep '\*' | cut -d' ' -f2-)
if [[ -z $(git config "branch.${CURRENT_BRANCH}.remote") ]]; then
echo "Doesn't look like you've pushed this branch to remote"
echo -e "Pushing now using: git push origin $CURRENT_BRANCH\n"
# Note: we need to set upstream as well or the gh pr create step will fail
# See: https://github.com/cli/cli/issues/575
git push -u origin "$CURRENT_BRANCH"
echo "Please set the upstream and re-run the script"
exit 1
fi
echo "Going to try to update vscode for you..."