Skip to content

Instantly share code, notes, and snippets.

@rhoboro
Last active December 7, 2022 03:10
Show Gist options
  • Save rhoboro/3b6404babfbaaddf881b206f6c4949f3 to your computer and use it in GitHub Desktop.
Save rhoboro/3b6404babfbaaddf881b206f6c4949f3 to your computer and use it in GitHub Desktop.
my first gh command extension
#!/usr/bin/env bash
# https://docs.github.com/en/github-cli/github-cli/creating-github-cli-extensions
# Put this script into ~/.local/share/gh/extensions/gh-dev-pr/gh-dev-pr
set -e
CURRENT_BRANCH=$(git branch --contains | awk '{print $2}')
MAIN_PR=$(gh pr list --json title,url -H ${CURRENT_BRANCH})
DEV_PR_TITLE=$(echo ${MAIN_PR} | jq -r '.[0].title' | sed 's/^\[main\]/[develop]/')
DEV_PR_BODY=$(echo ${MAIN_PR} | jq -r '.[0].url')
exec gh pr create --base develop --title "${DEV_PR_TITLE}" --body "${DEV_PR_BODY}" --head "${CURRENT_BRANCH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment