<?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>Jabbering Giraffe &#187; github</title>
	<atom:link href="http://happygiraffe.net/blog/tag/github/feed/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 20:49:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Publishing a subdirectory to github pages</title>
		<link>http://happygiraffe.net/blog/2009/07/04/publishing-a-subdirectory-to-github-pages/</link>
		<comments>http://happygiraffe.net/blog/2009/07/04/publishing-a-subdirectory-to-github-pages/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 01:06:29 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[jslint4java]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1545</guid>
		<description><![CDATA[I&#8217;ve written some HTML documentation for jslint4java. It lives in jslint4java-docs/src/main/resources in typical maven fashion. I&#8217;d like to get it published on github pages. The starting point is similar to their documentation. git symbolic-ref HEAD refs/heads/gh-pages rm .git/index git clean &#8230; <a href="http://happygiraffe.net/blog/2009/07/04/publishing-a-subdirectory-to-github-pages/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written some HTML documentation for <a href="http://code.google.com/p/jslint4java/">jslint4java</a>.  It lives in <a href="http://github.com/happygiraffe/jslint4java/tree/d9c53ab241c90a46dc9c551fe1bc96ec650608c5/jslint4java-docs/src/main/resources">jslint4java-docs/src/main/resources</a> in typical maven fashion.  I&#8217;d like to get it published on <a href="http://pages.github.com/">github pages</a>.</p>
<p>The starting point is similar to their documentation.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> symbolic-ref HEAD refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>gh-pages
<span style="color: #c20cb9; font-weight: bold;">rm</span> .git<span style="color: #000000; font-weight: bold;">/</span>index
<span style="color: #c20cb9; font-weight: bold;">git</span> clean <span style="color: #660033;">-fdx</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;My GitHub Page&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> index.html
<span style="color: #c20cb9; font-weight: bold;">git</span> add .
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;First pages commit&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin gh-pages</pre></div></div>

<p>That lands us with a brand spanking new branch to play with.  What I&#8217;d like to do is make a new commit on that branch, but from a tree which is <em>already in my repository</em>.  The magic word is <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit-tree.html"><code>git commit-tree</code></a>.  It needs two things: the id of the tree and the id of the parent commit to attach to.</p>
<p>The parent to attach to is easy.  It&#8217;s the tip of the <code>gh-pages</code> branch we just made.  <a href="http://www.kernel.org/pub/software/scm/git/docs/git-show-ref.html"><code>git show-ref</code></a> will let us know the id.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> show-ref <span style="color: #660033;">-s</span> refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>gh-pages
0a0c2a4ef1f9421b6f9537472c0f04fd6485d2cc</pre></div></div>

<p>The next bit is the tree we want to commit.  <a href="http://www.kernel.org/pub/software/scm/git/docs/git-ls-tree.html"><code>git ls-tree</code></a> is the tool for the job.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> ls-tree <span style="color: #660033;">-d</span> HEAD jslint4java-docs<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span>resources
040000 <span style="color: #c20cb9; font-weight: bold;">tree</span> 5feb5926c39b5e6af3a51feb04750c819bf08b94	jslint4java-docs<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span>resources</pre></div></div>

<p><code>git commit-tree</code> will return the id of the new commit it just created.  All that remains is to <a href="http://www.kernel.org/pub/software/scm/git/docs/git-update-ref.html">update</a> the <code>gh-pages</code> branch to point at it.</p>
<p>Pulling it all together, we have:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">parent_sha</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span> show-ref <span style="color: #660033;">-s</span> refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>gh-pages<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">doc_sha</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span> ls-tree <span style="color: #660033;">-d</span> HEAD jslint4java-docs<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span>resources <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3}'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">new_commit</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Auto-update docs.&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">git</span> commit-tree <span style="color: #007800;">$doc_sha</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$parent_sha</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> update-ref refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>gh-pages <span style="color: #007800;">$new_commit</span></pre></div></div>

<p>This isn&#8217;t ideal — it won&#8217;t automatically track updates to that directory.  But it&#8217;s easy enough to run this once in a while to publish an update.</p>
<p>The end result is that my documentation is <a href="http://happygiraffe.github.com/jslint4java/">published</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2009/07/04/publishing-a-subdirectory-to-github-pages/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Github Pages with Maven</title>
		<link>http://happygiraffe.net/blog/2009/01/17/github-pages-with-maven/</link>
		<comments>http://happygiraffe.net/blog/2009/01/17/github-pages-with-maven/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 00:44:38 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1454</guid>
		<description><![CDATA[Github recently introduced their pages feature, for serving static content. This sounds like an ideal match for a maven , so I thought I&#8217;d give it a go. I managed to get happygiraffe.github.com/tclogview/ up and running in fairly short order, &#8230; <a href="http://happygiraffe.net/blog/2009/01/17/github-pages-with-maven/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/">Github</a> recently introduced their <a href="http://github.com/blog/272-github-pages">pages</a> feature, for serving static content.  This sounds like an ideal match for a <a href="http://maven.apache.org/plugins/maven-site-plugin/">maven </a>, so I thought I&#8217;d give it a go.  I managed to get <a href="http://happygiraffe.github.com/tclogview/">happygiraffe.github.com/tclogview/</a> up and running in fairly short order, but I&#8217;m not totally happy with the end result.  And that&#8217;s not <em>just</em> the fault of the default maven site.</p>
<p>First things first.  We need to set up the gh-pages branch as devoid of content.  I nicked most of this from drnic&#8217;s <a href="http://maven.apache.org/plugins/maven-site-plugin/">sake-tasks</a>, even though the instructions are also on <a href="http://pages.github.com/">pages.github.com</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> symbolic-ref HEAD refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>gh-pages
<span style="color: #c20cb9; font-weight: bold;">rm</span> .git<span style="color: #000000; font-weight: bold;">/</span>index
<span style="color: #c20cb9; font-weight: bold;">git</span> clean <span style="color: #660033;">-fdx</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt;h1&gt;Coming soon!&lt;/h1&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span>index.html
<span style="color: #c20cb9; font-weight: bold;">git</span> add index.html
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'Initial page'</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin gh-pages</pre></div></div>

<p>Soon, you should be able to see the &#8220;Coming soon!&#8221; message on <code>you.github.com/yourproj/</code>.</p>
<p>Now that&#8217;s there, we need to set it up so that maven can deploy the site to it.  First, let&#8217;s add the branch as a <a href="http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html">submodule</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">repo</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">git</span> config remote.origin.url<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> submodule add <span style="color: #660033;">-b</span> gh-pages <span style="color: #007800;">$repo</span> site</pre></div></div>

<p>That should create a directory &#8220;site&#8221; which contains the index.html you committed a moment ago.  Now you have to ask Maven to deploy the site there.  Add this to your POM.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;distributionManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;site<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>gh-pages<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #808080; font-style: italic;">&lt;!-- This gets automatically pushed to the gh-pages branch. --&gt;</span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>file:${project.basedir}/site<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/site<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/distributionManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Now you can say <code>mvn site-deploy</code> and it will fill up the site directory with lots of lovely HTML.  Then you have to commit it (separately, since it&#8217;s a submodule) and push it back to github.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">  mvn site-deploy
  <span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #7a0874; font-weight: bold;">cd</span> site
    <span style="color: #c20cb9; font-weight: bold;">git</span> add .
    <span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'Generate site.'</span>
    <span style="color: #c20cb9; font-weight: bold;">git</span> push origin gh-pages
  <span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>And shortly thereafter it shows up on the web site.  Magic.</p>
<p>I like this a lot in principal.  But I have a few issues with it as well.  Mostly, this is down to git submodules being quite a blunt instrument:</p>
<ul>
<li>They don&#8217;t auto-update when there&#8217;s a new commit in the submodule — they point at a fixed commit.  You have to ask for it to be updated.</li>
<li>On top of that, you can&#8217;t point the submodule at a branch.  It&#8217;s always pointing at a specific commit.</li>
<li>The submodule location is recorded in <code>.gitmodules</code>.  The main issue I have with this is I can&#8217;t find a way to say &#8220;my current repository&#8221;.  Why is this a problem?  Well, if somebody forks the codebase (and they will, this is git) then they want their site to point at <em>their</em> gh-pages branch, not mine.</li>
<li>The submodule location is my private push URL, not the public one.  Which is all well and good, but when somebody checks out the project, they&#8217;re going to have an error when they try to check it out.  As I found out when setting up the build in <a href="https://hudson.dev.java.net/">hudson</a>.</li>
<li>When somebody else checks out the repository they have an extra step to go through to fetch the submodule contents (<code>git submodule init  git submodule update</code>).</li>
</ul>
<p>I think that next time I try this, I&#8217;ll skip submodules and just checkout a second copy of the repo in <code>../project-site</code>.</p>
<p>I still think it&#8217;s the right way to go.  Not just for the site, but you can also use github pages to serve up a maven repository in a very similar fashion.  Github and maven do seem to go together rather well.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2009/01/17/github-pages-with-maven/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

