<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>World Wide Mike &#187; software</title>
	<atom:link href="http://mmm.beachtemple.com/blog/tag/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://mmm.beachtemple.com/blog</link>
	<description>Notes from the Journey that is Life</description>
	<lastBuildDate>Sun, 12 Apr 2009 12:16:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Keep Your Source Clean: Don&#8217;t Worry About Generated Files</title>
		<link>http://mmm.beachtemple.com/blog/2009/04/12/keep-your-source-clean-dont-worry-about-generated-files/</link>
		<comments>http://mmm.beachtemple.com/blog/2009/04/12/keep-your-source-clean-dont-worry-about-generated-files/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 12:16:14 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[opensim]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://mmm.beachtemple.com/blog/?p=199</guid>
		<description><![CDATA[Don't dirty your source and don't worry about generated files.]]></description>
			<content:encoded><![CDATA[<p>Working with OpenSim recently, I didn&#8217;t want to have to worry about checking in generated files by accident, or filtering my <code>git status</code> output in order to determine what I changed and was generated. In this post, I&#8217;ll describe how I do this and outline some tools I use to make it easy.</p>
<p>The basic premise in my development style is that I build the project in a separate directory than where the checked out code lives:</p>
<pre>
# checked out code lives in ~/source/opensim
$ cd ~/source
$ svn co http://opensimulator.org/svn/opensim/trunk opensim

# the workspace is where I build and run the project
$ mkdir ~/source/workspace
</pre>
<p>Then, to build and run the code:</p>
<pre>
# first I rsync the code to the workspace, skipping .svn folders
# and other unneeded files
$ rsync -avz --exclude=\.svn [...] ~/source/opensim/ ~/source/workspace/

# then I run prebuild and compile
$ cd ~/source/workspace
$ mono bin/Prebuild.exe /target nant
$ nant
</pre>
<p>This way I never have to filter through generated files when inspecting or committing my changes, and I don&#8217;t commit generated files by mistake.</p>
<h3>Tools</h3>
<p>I have a set of scripts I use when developing OpenSim on Linux (I also use some of the scripts on Windows with cygwin). The scripts are <a href="http://github.com/mikem/opensim-dev-scripts/tree/master"> available on github</a>.</p>
<p>All those above commands are encapsulated in <a href="http://github.com/mikem/opensim-dev-scripts/blob/master/os_build.sh"><code>os_build.sh</code></a>, a single script which takes two arguments, the first is the name of the directory in <code>~/source/</code> in which the source<br />
lives, and the second is the name of the directory in <code>~/source/</code> in which to build:</p>
<pre>
# this one command performs the rsync, prebuild and nant steps from above
$ os_build.sh opensim workspace
</pre>
<p>Another key part is the <a href="http://github.com/mikem/opensim-dev-scripts/blob/master/os_clean_workspace.sh"><code>os_clean_workspace.sh</code></a> script which removes all build artifacts from the workspace directory, while keeping all configuration files in<br />
place. I use this whenever I need to do a clean build.</p>
<p>My typical session looks like this:</p>
<pre>
$ cd ~/source/opensim
$ git svn rebase                   # pull the latest changes from upstream
$ vim -p file1 file2 ...           # open the files I'll be working on

... edit source ...

$ os_build.sh opensim workspace    # rsync, prebuild, build

... in another terminal, run &#038; test ...
... make more edits ...

# sync only changed files, rebuild only what's needed
$ os_build_sh opensim workspace

... make big changes requiring clean build ...

# removes everything except config files
$ os_clean_workspace.sh workspace
$ os_build.sh opensim workspace
</pre>
<p>There are also other helper scripts for <a href="http://github.com/mikem/opensim-dev-scripts/blob/master/os_clean_database.sh">cleaning the database</a>, <a href="http://github.com/mikem/opensim-dev-scripts/blob/master/os_run_tests.sh">running unit tests</a>, and other tasks. Have a look!</p>
]]></content:encoded>
			<wfw:commentRss>http://mmm.beachtemple.com/blog/2009/04/12/keep-your-source-clean-dont-worry-about-generated-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>git post-receive Hook</title>
		<link>http://mmm.beachtemple.com/blog/2009/04/06/git-post-receive-hook/</link>
		<comments>http://mmm.beachtemple.com/blog/2009/04/06/git-post-receive-hook/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 00:16:09 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[buildbot]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://mmm.beachtemple.com/blog/?p=188</guid>
		<description><![CDATA[Notes on setting up automated tasks when commits are pushed to a central git repository.]]></description>
			<content:encoded><![CDATA[<p>At my job we use <a href="http://git-scm.com/">git</a> for version control, and I wanted to do a few things whenever we pushed changes to the main tree. It took me a little bit of effort to figure out how it works, and below are my notes.</p>
<p>The <code>post-receive</code> hook is called when the repository receives changes. Let&#8217;s assume I have a git repository on my development machine that is a clone of a public git repository on a server. Then, when I run <code>git push</code> in my local repository in order to push my commits to the public repository, the <code>post-receive</code> hook is called on the public repository on the server.</p>
<h3>Email Notification</h3>
<p>On Debian-based systems there is an example email notification post-receive hook in <code>/usr/share/doc/git-core/contrib/hooks/post-receive-email</code>. It&#8217;s also available online from the <a href="http://github.com/git/git/tree/master">git repo on github</a> in the <code>contrib/hooks</code> directory.</p>
<p>In the repository that will be receiving commits (the public repository on the server, in the example above), first we need to make the <code>post-receive</code> hook executable:</p>
<pre>
$ cd /path/to/git/repo/.git/hooks
$ chmod +x post-receive
</pre>
<p>Then we need to call the <code>post-receive-email</code> script from inside this <code>post-receive</code> hook. Open <code>.git/hooks/post-receive</code> with your favorite editor and make sure this line exists:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">. <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>post-receive-email</pre></div></div>

<p>Notice we&#8217;re not executing the <code>post-receive-email</code> script, we&#8217;re sourcing it.</p>
<p>Next, we need to tell git where to send the email to. The <code>hooks.mailinglist</code> property controls this:</p>
<pre>
$ cd /path/to/git/repo
$ git config hooks.mailinglist "mailinglist@example.com"
</pre>
<p>At this stage emails will be sent each time changes are pushed to the public git repository containing a summary of the new changes.</p>
<p>By default, emails refer to the project as &#8220;UNNAMED PROJECT&#8221;. To change this, edit <code>.git/description</code>.</p>
<p>For further customization options, look inside <code>post-receive-email</code>. For example:</p>
<pre>
$ cd /path/to/git/repo
# envelopesender? see `man sendmail` for the -f switch
$ git config hooks.envelopesender "git@example.com"
$ git config hooks.emailprefix "[MY PREFIX] "  # note the trailing space
</pre>
<h3>Kicking Off a Buildbot Build</h3>
<p>You may also want to have Buildbot start a build from the <code>post-receive</code> hook. Like the email script, the <a href="http://buildbot.net/trac/browser/contrib/git_buildbot.py">Buildbot git script</a> expects revision hashes on standard input. The <code>post-receive</code> script then needs to be modified a little to pass the hashes it receives via standard input to all the scripts it invokes. Here&#8217;s a new copy of <code>post-receive</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> oldrev newrev refname
<span style="color: #000000; font-weight: bold;">do</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$oldrev</span> <span style="color: #007800;">$newrev</span> <span style="color: #007800;">$refname</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>post-receive-email
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$oldrev</span> <span style="color: #007800;">$newrev</span> <span style="color: #007800;">$refname</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>git_buildbot.py
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>This script first reads <code>oldrev</code>, <code>newrev</code>, and <code>refname</code> from standard input, then pipes those values into <code>post-receive-email</code> and <code>git_buildbot.py</code>. We loop until there is no more input, presumably because another push may happen while we&#8217;re executing.</p>
]]></content:encoded>
			<wfw:commentRss>http://mmm.beachtemple.com/blog/2009/04/06/git-post-receive-hook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
