{"id":158,"date":"2011-03-31T08:51:29","date_gmt":"2011-03-31T12:51:29","guid":{"rendered":"http:\/\/fazigu.org\/blog\/?p=158"},"modified":"2011-03-31T08:54:18","modified_gmt":"2011-03-31T12:54:18","slug":"gitweb-diffs-between-versions","status":"publish","type":"post","link":"https:\/\/fazigu.org\/blog\/2011\/03\/31\/gitweb-diffs-between-versions\/","title":{"rendered":"Gitweb Diffs Between Versions"},"content":{"rendered":"<p>Our company deploys code into production primarily from our version control system.\u00a0 I suppose all companies do, in some way or another.\u00a0 We endured a long hell with CVS and a far shorter stint in the purgatory of Subversion before we went into the heavenly light of Git.<\/p>\n<p>The way we do it is to tag various branches destined for certain groups of machines, archive a snapshot, then copy those out to where they belong.\u00a0 This is all partially automated by an awesome (if somewhat Byzantine) home-grown software suite that I inherited once the original author left for (at least literally) greener pastures in the Pacific northwest.<\/p>\n<p>I&#8217;m not normally in charge of deployment, but since I &#8220;own&#8221; the software now and the usual dude is on a well-deserved vacation, this week I&#8217;m handling the once-weekly scheduled deploy and the multitude of little tweaks that absolutely positively must go out immediately.<\/p>\n<p>Our regular deployment manager sends out hand-written emails when he starts a test deploy, initiates the production deploy, then a final one when everything is finished.\u00a0 Myself,\u00a0 being a hacker, just can&#8217;t stomach the thought of not having something like that automated.\u00a0 Thus, I dug into the command that prints the deployment status of all servers and hacked it up to be slightly more informative and email-friendly, so I could just copy-and-paste its output to an email.<\/p>\n<p>Then I thought, as all hackers think, &#8220;Wouldn&#8217;t it be cool if I could include a link to Gitweb that shows the exact changes that occurred since the previous deploy?&#8221;\u00a0 I know the previous version commit-ish deployed to each\u00a0 server, and of course I know the new one, so I could do it quite easily with a simple git command.<\/p>\n<p>However, I didn&#8217;t want to just slap that command in there so someone could (and likely never would) issue it within their cloned repo.\u00a0 I wanted a simple clickable link to Gitweb.\u00a0 Anyway, the query ends up being something like this, tacked onto your own Gitweb URL, of course:<\/p>\n<p><tt>gitweb.pl?p=your-repo.git;a=commitdiff;hp=695de2d;h=fb7b608<\/tt><\/p>\n<p>Where <tt>hp<\/tt> is the previous commit-ish and <tt>h<\/tt> is the usual &#8220;current&#8221; commit-ish argument.<\/p>\n<p>Voil\u00e0!<\/p>\n<p>The next step was to group all the servers by common changes so there&#8217;s only one diff link per group, and next I might try adding an <tt>--email-to<\/tt> option to send the email, skipping the copy-and-paste.<\/p>\n<p>&#8230;and then I&#8217;ll work on the bugs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our company deploys code into production primarily from our version control system.\u00a0 I suppose all companies do, in some way or another.\u00a0 We endured a long hell with CVS and a far shorter stint in the purgatory of Subversion before we went into the heavenly light of Git. The way we do it is to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[22],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-hacking","tag-git"],"_links":{"self":[{"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/comments?post=158"}],"version-history":[{"count":6,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/posts\/158\/revisions\/165"}],"wp:attachment":[{"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/media?parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/categories?post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/tags?post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}