No two Git workflows are the same. Every development team is different and so are the workflows they are using. It is impossible to come up with one single “best practice” that will work for all development teams out there. In Stash 2.1 we simplified Git development workflow by providing important information that affect the changes in a pull request – Jira issues and Bamboo builds. Today’s release of Stash 2.2 takes it to the next level with several capabilities – repository hooks, an API for hook integrations and merge checks during pull requests – to customize your Git development workflow to any requirements and ensure code quality.
The new, more customizable Stash – now with Git hooks
For those new to hooks, here is a quick primer: every time Git performs an action, you have the option to take an action before or after Git does its bit. “Hooks” are Git’s built-in mechanism to allow a “hook into” operations like commits, pushes, etc. For example: a hook can act as a rule preventing commits that violate your project’s code style from being pushed to your repository, or it could trigger a build on your continuous integration server every time a feature branch is updated.
In Stash 2.2, we leveraged the native Git hooks to create a new hooks API that allows development teams to easily enable, manage and configure hooks per-repository. Hooks in Stash have a few key advantages beyond their native Git counterparts:
- Developers can write hooks using a simple hooks API. Stash handles persistence, packaging and per-repository configuration for your hooks, making it simple to extend Stash to suit your particular project’s needs.
- Admins no longer have to install hooks on the file-system, or give developers access. They can easily manage hooks running in their repositories and enable/configure the hooks via repository settings, all while keeping the server locked down.
- Development teams can mix-and-match out-of-the-box Stash hooks, with additional hooks from the Atlassian Marketplace, to customize and automate their git workflow.
Hook into your Git workflow
Git hooks let you customize your team’s workflow to any requirement they may have, and automate more pieces of your development workflow.
Start customizing with Git hooks
Stash’s new out-of-the-box pre-receive (reject commits that don’t match your policies) and post-receive (perform actions after commits are processed) repository hooks enable you to configure Stash to work the way you work – quickly and easily.
Avoid the “oh sh–” moment: at some point when learning Git, you have probably heard “when in doubt, don’t force-push”. Prevent force pushes to a repository (which is particularly handy if your team is new to Git), and avoid removing any history from your repository with the Prevent Force Push hook.
Keep development teams in the loop via Hipchat: when it’s close to release time, gatekeepers may vet everything coming into a release branch. With the Hipchat hook, whenever changes get pushed to a repository, teams get instantly notified in a Hipchat room.
Don’t see the hook you need out-of-the-box? Stash makes it simple to install additional hooks available on Atlassian Marketplace. Over time, Atlassian and the Stash community will contribute more and more hooks to the Marketplace to adjust your workflow.
Several are already available today:
Iterate smarter: ensure that reviewers approve all updates to pull requests and prevent late-breaking bugs from creeping in during rework. With the Unapprove Reviewers hook if there is an update to the source branch in the pull request all reviewers will automatically be set to unapproved.
Keep branches protected: branches can be deleted accidentally when they are still active (read: not merged). The Protect Unmerged Branch hook rejects all pushes that delete branches with active pull requests.
Pull request settings – enforce your workflow
Stash pull requests aim to keep code quality high by ensuring code has gone through peer review before being merged into your master branch. In Stash 2.1, we simplified your Git development workflow by providing key information about Jira issues and Bamboo builds in pull requests, giving you a quick idea of whether or not the changes are good to merge. In Stash 2.2, we set the bar even higher by enabling you to enforce certain quality requirements and ensure they are met before a pull request can be merged.
- Tailor your workflow: set checks to control when a pull request can be merged, per-repository.
- Guarantee code quality: whether you require a minimum number of reviewers approving a request or a green build, pull requests cannot be merged if the required checks have not been met.
- Increase development efficiency: developers spend less time investigating changes and more time coding.
Require a minimum number of builds
Stash integrates seamlessly with build automation tools like Bamboo and Jenkins, putting build details at your fingertips on the pull request’s overview. In Stash 2.2, we took this integration a step further. With pull request settings you can now stop pull requests from being merged unless all the related builds are successful.
Require a minimum number of approvers
On the Stash development team, we require at least two approvals before merging a pull request. Until today, this was just a cultural discipline – part of our development process. In Stash 2.2 you can make this discipline a requirement. Administrators (including project admins) have the option to block merging of a pull request until it has been approved by at least a select number of reviewers. It’s seamless, it’s automated and it’s easy to update as your team’s processes evolve.
The growing Stash ecosystem
Stash has been built from the ground up with extensibility in mind. With Stash 2.2 we are taking that extensibility to the next level and providing the world’s most customisable Git repository management solution. Stash provides a vast number of plugin points and a comprehensive REST API that allows developers to create custom functionality and integrations.
With this release we are adding more to Stash’s powerful API to improve the experience that native Git hooks provide, hooks API. This will provide a huge lift in the growing Stash ecosystem and give you one more tool in your development tool belt to extend Stash’s capabilities.
Add-on or build it
A growing number of developers are sharing their customizations as free or paid add-ons through the Atlassian Marketplace (35+ are available). Get detailed stats on your commit history, motivate your development team by rewarding them with useful badges for pushing code or contribute an add-on of your own to the Atlassian Codegeist competition (there is a $10,000 Stash prize).
Get hooked on Stash
New to Stash? Start a free trial today and get up and running in a matter of minutes.
Already hooked on Stash? Your upgrade to 2.2 is waiting for you. Check out our full release notes to get started.