Skip to content

Instantly share code, notes, and snippets.

@netchampfaris
Created August 2, 2019 07:49
Show Gist options
  • Save netchampfaris/b0c5faa4dc725c15d89018ca2de0b48f to your computer and use it in GitHub Desktop.
Save netchampfaris/b0c5faa4dc725c15d89018ca2de0b48f to your computer and use it in GitHub Desktop.
Bash functions to create multiple PRs from the current branch

Usage

  1. Put the contents of this file in your .zshrc or .zprofile (if you use ZSH) or .bash_profile (if you use Bash)
  2. Open a new terminal

Note: You need hub command line tool for this to work. Get it here https://hub.github.com/

What does it do?

make-2-prs

You should build the feature from version-12-hotfix for this to work.

  1. Pushes the current branch to your origin
  2. Creates a Pull Request for version-12-hotfix branch
  3. Creates a new branch with the name "{branch-name}-fp"
  4. Cherry picks the last commit
  5. Pushes the branch to your origin
  6. Creates a Pull Request for develop branch

make-3-prs

You should build the feature from version-11-hotfix for this to work.

Same as above, but will make PRs to version-11-hotfix, version-12-hotfix and develop.

make-3-prs() {
push-and-pr version-11-hotfix
new-branch-and-cherry-pick version-12-hotfix
push-and-pr version-12-hotfix
new-branch-and-cherry-pick develop
push-and-pr develop
}
make-2-prs() {
push-and-pr version-12-hotfix
new-branch-and-cherry-pick develop
push-and-pr develop
}
new-branch-and-cherry-pick() {
current_branch=$(git branch | grep \* | cut -d ' ' -f2)
last_commit=$(git log --format="%h" -n 1)
git checkout -B "$current_branch-fp" upstream/$1
git cherry-pick "$last_commit"
}
push-and-pr() {
git push origin head
hub pull-request -b frappe:$1 --no-edit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment