- Andrew Hagedorn
- Articles
- Open Github to Create a PR from the Command Line
Open Github to Create a PR from the Command Line
This is an archive of the random commands I have found useful. You may or may not, but the next time I need them I will know where to find them.
My team uses Github for reviewing pull requests prior to merging in code. This script avoids navigating to github and finding your branch and dumps you automatically into the PR creation flow for the current branch of the repository you are in:
function pr {
REPOURL=$(git config --get remote.origin.url)
REPOURL=${REPOURL/.git/}
REPOURL=${REPOURL/git@github.com:/}
BRANCH=$(git rev-parse --abbrev-ref HEAD)
BODY="@CodeReviewrsYouWant"$'
'"Description"$'
'"==="$'
'"Some description"
URL="https://github.com/$REPOURL"
URL="$URL/compare/master...$BRANCH?expand=1&body=$BODY"
open "$URL"
}
When used your default browser should open up with this screen:
Other Posts
Technology
- React SSR at Scale
- TravisCI, TeamCity, and Kotlin
- The Good and the Bad of Cypress
- Scaling Browser Interaction Tests
- Exploring Github Actions
- Scope and Impact
- Microservices: Back to the Future