<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Git and XCode: A git build number script</title>
	<atom:link href="http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/</link>
	<description>Taglines are for Windows programmers</description>
	<lastBuildDate>Sat, 13 Mar 2010 01:16:03 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: stompy</title>
		<link>http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/comment-page-1/#comment-791</link>
		<dc:creator>stompy</dc:creator>
		<pubDate>Tue, 26 Aug 2008 18:31:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=95#comment-791</guid>
		<description>&lt;p&gt;git rev-parse --short HEAD will give you the shorter unique sha-1.&lt;/p&gt;

&lt;p&gt;Also, rather than {WRAPPER_NAME} and the rest,  you could use {INFOPLIST_PATH} instead.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>git rev-parse &#8211;short HEAD will give you the shorter unique sha-1.</p>

<p>Also, rather than {WRAPPER_NAME} and the rest,  you could use {INFOPLIST_PATH} instead.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Cobber</title>
		<link>http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/comment-page-1/#comment-675</link>
		<dc:creator>Cobber</dc:creator>
		<pubDate>Sat, 14 Jun 2008 15:19:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=95#comment-675</guid>
		<description>&lt;p&gt;Thanks for posting your script!&lt;/p&gt;

&lt;p&gt;I found that &#039;git-describe --long&#039; gives a perfect format for typical versioning:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $git_description = qx{ git-describe --long };
my ( $release, $patch, $commit ) = ( $git_description =~ /([^-]+)-(\d+)-g(\w+)/ );
$release .= &quot;.$patch&quot; if $patch;
print &quot;Version $release (Build: $commit)\n&quot;;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can then tag your releases as 1.0, 2.6 etc, and the above lines will produce something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Version 1.0.5 (Build: 7abc23f)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I also added the following commands to the top of the script to automatically commit the current state, which then automatically bumps up the patch number... sweet!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use POSIX;
my $timestamp = strftime( &quot;[%Y-%m-%d %H:%M:%S %z]&quot;, localtime() );
system( qw{ git-add . } );
system( &quot;git-commit&quot;, &quot;-a&quot;, &quot;-m&quot;, &quot;$timestamp automatic build commit&quot; );
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So with these changes, and an appropriate run-script build rule, every build can be re-created at the drop of a hat.&lt;/p&gt;

&lt;p&gt;Problem solved.
Thanks!
(yeah there are ways to mess this up by using git-rebase etc, but this follows my development &quot;happy path&quot; perfectly)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for posting your script!</p>

<p>I found that &#8216;git-describe &#8211;long&#8217; gives a perfect format for typical versioning:</p>

<pre><code>my $git_description = qx{ git-describe --long };
my ( $release, $patch, $commit ) = ( $git_description =~ /([^-]+)-(\d+)-g(\w+)/ );
$release .= ".$patch" if $patch;
print "Version $release (Build: $commit)\n";
</code></pre>

<p>You can then tag your releases as 1.0, 2.6 etc, and the above lines will produce something like:</p>

<pre><code>Version 1.0.5 (Build: 7abc23f)
</code></pre>

<p>I also added the following commands to the top of the script to automatically commit the current state, which then automatically bumps up the patch number&#8230; sweet!</p>

<pre><code>use POSIX;
my $timestamp = strftime( "[%Y-%m-%d %H:%M:%S %z]", localtime() );
system( qw{ git-add . } );
system( "git-commit", "-a", "-m", "$timestamp automatic build commit" );
</code></pre>

<p>So with these changes, and an appropriate run-script build rule, every build can be re-created at the drop of a hat.</p>

<p>Problem solved.
Thanks!
(yeah there are ways to mess this up by using git-rebase etc, but this follows my development &#8220;happy path&#8221; perfectly)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: BastiH</title>
		<link>http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/comment-page-1/#comment-625</link>
		<dc:creator>BastiH</dc:creator>
		<pubDate>Fri, 06 Jun 2008 22:58:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=95#comment-625</guid>
		<description>&lt;p&gt;Thanks for this script. I looked a bit around and find the following command which will give you the number of commits into a git branch: &quot;git rev-list HEAD &#124; wc -l&quot;&lt;/p&gt;

&lt;p&gt;I ve put this into a small ruby script which will use this number and set it as the build number.&lt;/p&gt;

&lt;h1&gt;!/usr/bin/ruby&lt;/h1&gt;

&lt;p&gt;require &quot;rubygems&quot;
require &quot;Plist&quot;&lt;/p&gt;

&lt;p&gt;pl = Plist::parse_xml(ENV[&#039;BUILT_PRODUCTS_DIR&#039;] + &quot;/&quot; + ENV[&#039;WRAPPER_NAME&#039;] + &quot;/Contents/Info.plist&quot;)&lt;/p&gt;

&lt;p&gt;pl[&quot;CFBundleVersion&quot;] = &lt;code&gt;/usr/local/git/bin/git rev-list HEAD &#124; wc -l&lt;/code&gt;.to_i.to_s&lt;/p&gt;

&lt;p&gt;pl.save_plist(ENV[&#039;BUILT_PRODUCTS_DIR&#039;] + &quot;/&quot; + ENV[&#039;WRAPPER_NAME&#039;] + &quot;/Contents/Info.plist&quot;)&lt;/p&gt;

&lt;p&gt;Please be aware that you have to have the Plist gem installed and that my git is in another directory when somebody wants to use it.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for this script. I looked a bit around and find the following command which will give you the number of commits into a git branch: &#8220;git rev-list HEAD | wc -l&#8221;</p>

<p>I ve put this into a small ruby script which will use this number and set it as the build number.</p>

<h1>!/usr/bin/ruby</h1>

<p>require &#8220;rubygems&#8221;
require &#8220;Plist&#8221;</p>

<p>pl = Plist::parse_xml(ENV['BUILT_PRODUCTS_DIR'] + &#8220;/&#8221; + ENV['WRAPPER_NAME'] + &#8220;/Contents/Info.plist&#8221;)</p>

<p>pl["CFBundleVersion"] = <code>/usr/local/git/bin/git rev-list HEAD | wc -l</code>.to_i.to_s</p>

<p>pl.save_plist(ENV['BUILT_PRODUCTS_DIR'] + &#8220;/&#8221; + ENV['WRAPPER_NAME'] + &#8220;/Contents/Info.plist&#8221;)</p>

<p>Please be aware that you have to have the Plist gem installed and that my git is in another directory when somebody wants to use it.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: daniellord</title>
		<link>http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/comment-page-1/#comment-592</link>
		<dc:creator>daniellord</dc:creator>
		<pubDate>Tue, 06 May 2008 17:58:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=95#comment-592</guid>
		<description>&lt;p&gt;And, of course, the PyObjC version for Mercurial for fans of Hg like me:&lt;/p&gt;

&lt;h1&gt;!/usr/bin/env python&lt;/h1&gt;

&lt;p&gt;import os
from Foundation import NSMutableDictionary&lt;/p&gt;

&lt;p&gt;version = os.popen4(&quot;/usr/local/bin/hg log -r tip &#124; grep &#039;^changeset&#039; &#124; sed s/changeset://&quot;)[1].read()
info = os.environ[&#039;BUILT_PRODUCTS_DIR&#039;]+&quot;/&quot;+os.environ[&#039;WRAPPER_NAME&#039;]+&quot;/Contents/Info.plist&quot;&lt;/p&gt;

&lt;p&gt;plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info)
plist[&#039;CFBundleVersion&#039;] = version
plist.writeToFile_atomically_(info, 1)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>And, of course, the PyObjC version for Mercurial for fans of Hg like me:</p>

<h1>!/usr/bin/env python</h1>

<p>import os
from Foundation import NSMutableDictionary</p>

<p>version = os.popen4(&#8220;/usr/local/bin/hg log -r tip | grep &#8216;^changeset&#8217; | sed s/changeset://&#8221;)[1].read()
info = os.environ['BUILT_PRODUCTS_DIR']+&#8221;/&#8221;+os.environ['WRAPPER_NAME']+&#8221;/Contents/Info.plist&#8221;</p>

<p>plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info)
plist['CFBundleVersion'] = version
plist.writeToFile_atomically_(info, 1)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: prio</title>
		<link>http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/comment-page-1/#comment-582</link>
		<dc:creator>prio</dc:creator>
		<pubDate>Tue, 29 Apr 2008 13:34:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=95#comment-582</guid>
		<description>&lt;p&gt;Using the command suggested by kevinoneill, a slightly less reg-ex&#039;y version :)&lt;/p&gt;

&lt;p&gt;import os
from Foundation import NSMutableDictionary&lt;/p&gt;

&lt;p&gt;version = os.popen4(&quot;/opt/local/bin/git rev-parse HEAD&quot;)[1].read()
info = os.environ[&#039;BUILT_PRODUCTS_DIR&#039;]+&quot;/&quot;+os.environ[&#039;WRAPPER_NAME&#039;]+&quot;/Contents/Info.plist&quot;&lt;/p&gt;

&lt;p&gt;plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info)
plist[&#039;CFBundleVersion&#039;] = version
plist.writeToFile_atomically_(info, 1)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Using the command suggested by kevinoneill, a slightly less reg-ex&#8217;y version :)</p>

<p>import os
from Foundation import NSMutableDictionary</p>

<p>version = os.popen4(&#8220;/opt/local/bin/git rev-parse HEAD&#8221;)[1].read()
info = os.environ['BUILT_PRODUCTS_DIR']+&#8221;/&#8221;+os.environ['WRAPPER_NAME']+&#8221;/Contents/Info.plist&#8221;</p>

<p>plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info)
plist['CFBundleVersion'] = version
plist.writeToFile_atomically_(info, 1)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: daniellord</title>
		<link>http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/comment-page-1/#comment-562</link>
		<dc:creator>daniellord</dc:creator>
		<pubDate>Thu, 17 Apr 2008 19:53:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=95#comment-562</guid>
		<description>&lt;p&gt;Nice script. I use Mercurial instead of git, so I hacked your script to use the revision number and 12-char  changeset hash mercurial uses. It gets the job done. Thanks.&lt;/p&gt;

&lt;h1&gt;Xcode auto-versioning script for Subversion by Axel Andersson&lt;/h1&gt;

&lt;h1&gt;Updated for git by Marcus S. Zarra and Matt Long&lt;/h1&gt;

&lt;h1&gt;Updated for Mercurial by Daniel Lord&lt;/h1&gt;

&lt;p&gt;use strict;&lt;/p&gt;

&lt;h1&gt;Get the current Mercurial revision number and 12-char truncated changeset hash&lt;/h1&gt;

&lt;h1&gt;and use it to set the CFBundleVersion value e.g. 0:b1f34247e734&lt;/h1&gt;

&lt;p&gt;my $REV =&lt;code&gt;/usr/local/bin/hg log -r tip &#124; grep &quot;^changeset&quot;&lt;/code&gt;;
my $INFO = &quot;$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Contents/Info.plist&quot;;&lt;/p&gt;

&lt;p&gt;my $version = $REV;
if ( $version =~ /^changeset:\s*([0-9]+[:]{1}[0-9a-z]+)$/ )
{
    $version = $1;
}
else
{
    $version = undef;
}
die &quot;$0: No Mercurial changeset found&quot; unless $version;&lt;/p&gt;

&lt;p&gt;open(FH, &quot;$INFO&quot;) or die &quot;$0: $INFO: $!&quot;;
my $info = join(&quot;&quot;, );
close(FH);&lt;/p&gt;

&lt;p&gt;$info =~ s/([\t ]+CFBundleVersion\n[\t ]+).*?()/$1$version$2/;&lt;/p&gt;

&lt;p&gt;open(FH, &quot;&gt;$INFO&quot;) or die &quot;$0: $INFO: $!&quot;;
print FH $info;
close(FH);&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Nice script. I use Mercurial instead of git, so I hacked your script to use the revision number and 12-char  changeset hash mercurial uses. It gets the job done. Thanks.</p>

<h1>Xcode auto-versioning script for Subversion by Axel Andersson</h1>

<h1>Updated for git by Marcus S. Zarra and Matt Long</h1>

<h1>Updated for Mercurial by Daniel Lord</h1>

<p>use strict;</p>

<h1>Get the current Mercurial revision number and 12-char truncated changeset hash</h1>

<h1>and use it to set the CFBundleVersion value e.g. 0:b1f34247e734</h1>

<p>my $REV =<code>/usr/local/bin/hg log -r tip | grep "^changeset"</code>;
my $INFO = &#8220;$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Contents/Info.plist&#8221;;</p>

<p>my $version = $REV;
if ( $version =~ /^changeset:\s*([0-9]+[:]{1}[0-9a-z]+)$/ )
{
    $version = $1;
}
else
{
    $version = undef;
}
die &#8220;$0: No Mercurial changeset found&#8221; unless $version;</p>

<p>open(FH, &#8220;$INFO&#8221;) or die &#8220;$0: $INFO: $!&#8221;;
my $info = join(&#8220;&#8221;, );
close(FH);</p>

<p>$info =~ s/([\t ]+CFBundleVersion\n[\t ]+).*?()/$1$version$2/;</p>

<p>open(FH, &#8220;&gt;$INFO&#8221;) or die &#8220;$0: $INFO: $!&#8221;;
print FH $info;
close(FH);</p>]]></content:encoded>
	</item>
	<item>
		<title>By: kevinoneill</title>
		<link>http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/comment-page-1/#comment-544</link>
		<dc:creator>kevinoneill</dc:creator>
		<pubDate>Mon, 14 Apr 2008 03:24:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=95#comment-544</guid>
		<description>&lt;p&gt;you may want to give &#039;git rev-parse HEAD&#039; a try. it&#039;ll give you just the sha1 without the need for all of that scary regex magic :).&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>you may want to give &#8216;git rev-parse HEAD&#8217; a try. it&#8217;ll give you just the sha1 without the need for all of that scary regex magic :).</p>]]></content:encoded>
	</item>
</channel>
</rss>
