New blog post! read about Cherry Pie on Medium: Crafting the perfect Pull Request by Shlomo Kraus
This extension adds a button to Github's Pull Request page that extracts files from one branch and stage them into a new one. That way you can submit PRs with minimum relevant changes, even if you didn't plan ahead.
Honestly, you’ve worked hard on that feature, but when you opened the pull request you can clearly see it would've made more sense to split it into multiple smaller updates, each with its own PR.
Since your commit history is unreadable, you can't use
git cherry-pick and wish you could go back in time and turn it into something that plays nicely in
Now you can.
INSTALL & USAGE
- Install the extension from Chrome store.
- You will see a
Slicebutton appears in every pull request files tab.
- After selecting files you will notice a purple button appears at the toolbar, clicking it will open Cherry Pie interface as a modal.
- You will need to add your credentials, either password or token.
- Review changes, enter pull request title and click Slice!
Cherry picking is a perfect git command which, in a perfect world, allows a perfect programmer to carefully pick her commits and stage them into a new branch, where they can be pulled into master in perfectly organized pieces.
But we are not perfect, we are developers
Though our code is clean, our feature branch’s commits are “WIP” or “fix” or “here’s another try” and essentially - just a whole big mess waiting to be squashed.
If you can't pick, then slice!
Cherry Pie let’s you work your way backwards: Pick any number of files from a branch (instead of commits) and move them into a whole new branch.
That way you can split a long pull request into numerous atomic and clean ones, with descriptive titles. Bugs will be easier to spot, reverts become a breeze and the guy over there doing your CR would be so thankful he’ll bake you a pie. A real one for sure.
Is this needed?
Pull requests should be small, surgical, keeping only the minimum required updates. But it is easier said than done. In our team we constantly trying to keep PRs small but it can't be done without over-complicating the workflow.
Since cherry-pick is not always possible (as explained before), you need to manually go, create a branch, checkout the requested files and...just skip the whole process goes who got time.
This extension rose from endless hours of reviewing pull requests where the thought "I wish could just click and split this PR" constantly troubled my restful mind.
What's with the name?
cherry-pick for commits, but when commit history is squashed, it turns into a cherry pie. So - if you
pick a cherry, you need to
slice a cherry pie.
DEVELOPMENT & CONTRIBUTION
Feel free to request and add features through pull requests. If you got this far you know the rules.
yarn run build
Will compile and build a local version inside
dist folder. Install the extension by going to chrome extension page and clicking
Load Unpacked then directing to this folder.
yarn run watch
Will build the package and also reload it whenever you make a change.
yarn run storybook
Storybook is setup for easier development of the views.
This extension uses integration and e2e tests.
Tests are ran using puppeteer. They load the extension in chroium, checks that it is loaded and injected correctly and tests some basic UX paths. The tests are located in
Those tests run against the repo
cherrypie-test. Configuration is managed with
node-config and files located in the
config directory. You should learn how
node-config works, but essentialy, we have default config which should be override. The file
default.json contains the non sensitive data needed for tests.
The sensitive data which is
github.password must never be commited to the repo. You can either set them using environment variables when running the tests (that's how it is done on circleci), or you can add a
config/local-test.json file which is merged to default.json when running the tests. This file is ignored by git and used only for local development.
If you can't pick cherries, slice a cherry pie