The Artima Developer Community
Sponsored Link

Java Buzz Forum
How Stash Developers Avoid Branching from a Bad Commit

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mathias Bogaert

Posts: 618
Nickname: pathos
Registered: Aug, 2003

Mathias Bogaert is a senior software architect at Intrasoft mainly doing projects for the EC.
How Stash Developers Avoid Branching from a Bad Commit Posted: May 1, 2013 5:25 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Mathias Bogaert.
Original Post: How Stash Developers Avoid Branching from a Bad Commit
Feed Title: Scuttlebutt
Feed URL: http://feeds.feedburner.com/AtlassianDeveloperBlog
Feed Description: tech gossip by mathias
Latest Java Buzz Posts
Latest Java Buzz Posts by Mathias Bogaert
Latest Posts From Scuttlebutt

Advertisement
One of my colleagues recently blogged about how the Confluence team avoids creating feature branches from bad commits. This blog post describes how to take the same idea one step further. The Problem I hate it when I make a trivial change, something like: 123456789$ git checkout master Switch to branch 'master'   $ git checkout -b STASHDEV-1234-fix-capitalisation-of-Stash Switched to a new branch 'STASHDEV-1234-fix-capitalisation-of-Stash'   .. change capitalization of one word in a template ..   $ git commit -m "STASHDEV-1234: Totally trivial change" && git push --set-upstream origin STASHDEV-1234-fix-capitalisation-of-Stash Then a few minutes later.. *BOOM* What the heck? How did changing the capitalization of a letter break the database migration tests? Hmm.. maybe they’re flakey. Let’s re-run the build. *BOOM* Arggh! Oh wait. Of course. I know what heinous crime I’ve committed! 12$ git checkout master $ git checkout -b STASHDEV-1234-fix-capitalisation-of-Stash Little did I know, one of my co-workers had broken master at some point in the past. My crime: branching from their broken commit. A simple merge from master at this point (providing it’s green) will remedy the situation, even if it does make the history a bit uglier. Wouldn’t it be nice if we could avoid this whole situation altogether? The Solution What if git warned you when you switched to a dodgy ref? Something like: 12345$ git checkout master master is lookin' good! c4f3b4b has 4 green builds.   $ git checkout stable-2.3 DANGER! stable-2.3 is busted. e1324fa has 2 red builds. Then you could easily switch back to a better ref for your branch point, or slap the build breaker until they fix it. I’ve built a little client-side git hook that does exactly that. It will work work for any git repository built by Bamboo, and is super easy to install. Just run this command from the root of your local clone: 1sh <(curl -s https://bitbucket.org/tpettersen/post-checkout-build-status/raw/master/install.sh) You’ll be prompted for the url and credentials of either: the Bamboo server that builds your repository; or the Stash server that hosts your repository (if you’ve set up your CI server to notify Stash of build results). 1234567$ sh <(curl -s https://bitbucket.org/tpettersen/post-checkout-build-status/raw/master/install.sh) Retrieve build status from (S)tash or (B)amboo? B Bamboo URL: bamboo.atlassian.com Username: tpettersen Password: Installing hook... post-update hook installed. Config written to .git/hooks/bamboo-config.yml It works by registering a post-checkout hook that hits a little known REST end-point in Bamboo that provides all build results for a particular SHA. The project is up on Bitbucket and I’m very open to pull requests.

Read: How Stash Developers Avoid Branching from a Bad Commit

Topic: Keep It Fun Previous Topic   Next Topic Topic: When Maven Dependency Plugin Lies

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use