logo

blog

My cute blog can’t be this disorganised!

My git server setup.html (2291B)


      1 <h1><a href="/articles/My%20git%20server%20setup">My git server setup</a></h1>
      2 <p>So after having problems with gitlab.com (not being able to push to your own repository for example). I decided to have a very simple git setup, inspired by git.linkmauve.fr. I putted all my git repos into <code>/git</code>.</p>
      3 <h2>started with just nginx and ssh</h2>
      4 <p>This one is dead-simple when you know the trick, simply put <code>git update-server-info</code> into hooks/post-update of your git repo (they have to be bare repo, that’s done with --bare)</p>
      5 <h2>Added git-daemon</h2>
      6 <p>That one was even more simple, just had to point to where the git repositories are stored</p>
      7 <h2>Wanted a better interface</h2>
      8 <p>While searching for alternatives to GNU I saw <a href="http://git.2f30.org/stagit/">stagit</a>, a static git generator (I don’t like CGI, specially when it could have access to my git repos), to use it I added theses lines to the post-update-hook
      9 <pre><code>repo=$(pwd)
     10 cd "$(pwd | sed s/.git$//)" &amp;&amp; stagit -c "$repo.cache" "$repo"
     11 cd /git &amp;&amp; stagit-index *.git &gt; /git/index.html</code></pre></p>
     12 <h2>Deployement to blog</h2>
     13 <p>This one output an error(probably because the GIT_INDEX_FILE should not be empty) but it works so who cares :P</p>
     14 <code>GIT_INDEX_FILE='' git --work-tree=/srv/web/hacktivis.me --git-dir=/git/blog.git checkout -f</code>
     15 <h2>Garbage Collector</h2>
     16 <p>It’s not like my repos were getting big, git is supposed to do that itself but it seems like it doesn’t, so I’m doing <code>git gc</code> each time, which isn’t very optimised.</p>
     17 <h2>Final post-update hook</h2>
     18 <pre><code>
     19 #!/bin/sh
     20 repo=$(pwd)
     21 update_f=' * Updating %s…'
     22 is_ok(){ echo ' [OK]'; }
     23 
     24 printf "$update_f" 'Garbage Collector'
     25 git gc &amp;&amp; is_ok
     26 
     27 printf "$update_f" info
     28 git update-server-info &amp;&amp; is_ok
     29 
     30 printf "$update_f" stagit
     31 cd "$(pwd | sed s/.git$//)" &amp;&amp; stagit -c "$repo.cache" "$repo" &amp;&amp; is_ok
     32 
     33 printf "$update_f" stagit-index
     34 cd /git &amp;&amp; stagit-index *.git &gt; /git/index.html &amp;&amp; is_ok
     35 
     36 # Errors but works
     37 grep blog &lt;&lt;&lt;$repo &amp;&amp; printf "$update_f" blog &amp;&amp; GIT_INDEX_FILE='' git --work-tree=/srv/web/hacktivis.me --git-dir=/git/blog.git checkout -f &amp;&amp; is_ok
     38 </code></pre>