logo

blog

My little blog can’t be this cute! git clone https://hacktivis.me/git/blog.git
commit: 12fc01c2fe4bf2619f680a87378419dc37ad8407
parent 9019659d089d6657e9187ab2bafc5d111366ef1e
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 11 Feb 2019 02:08:09 +0100

articles/My git server setup: link to hook code repository, dumb http can be done with post-receive too

Diffstat:

Marticles/My git server setup.html29++++-------------------------
1 file changed, 4 insertions(+), 25 deletions(-)

diff --git a/articles/My git server setup.html b/articles/My git server setup.html @@ -1,7 +1,7 @@ <h1 class="p-name"><a class="u-url" href="/articles/My%20git%20server%20setup">My git server setup</a></h1> <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> <h2>started with just nginx and ssh</h2> -<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> +<p>This one is dead-simple when you know the trick, simply put <code>git update-server-info</code> into <code>hooks/post-update</code> or <code>hooks/post-receive</code> of your git repo (they have to be bare repo, that’s done with --bare)</p> <h2>Added git-daemon</h2> <p>That one was even more simple, just had to point to where the git repositories are stored</p> <h2>Wanted a better interface</h2> @@ -9,30 +9,9 @@ <pre><code>repo=$(pwd) cd "$(pwd | sed s/.git$//)" &amp;&amp; stagit -c "$repo.cache" "$repo" cd /git &amp;&amp; stagit-index *.git &gt; /git/index.html</code></pre></p> -<h2>Deployement to blog</h2> -<p>This one output an error(probably because the GIT_INDEX_FILE should not be empty) but it works so who cares :P</p> -<code>GIT_INDEX_FILE='' git --work-tree=/srv/web/hacktivis.me --git-dir=/git/blog.git checkout -f</code> <h2>Garbage Collector</h2> <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> -<h2>Final post-update hook</h2> -<pre><code> -#!/bin/sh -repo=$(pwd) -update_f=' * Updating %s…' -is_ok(){ echo ' [OK]'; } - -printf "$update_f" 'Garbage Collector' -git gc &amp;&amp; is_ok - -printf "$update_f" info -git update-server-info &amp;&amp; is_ok - -printf "$update_f" stagit -cd "$(pwd | sed s/.git$//)" &amp;&amp; stagit -c "$repo.cache" "$repo" &amp;&amp; is_ok - -printf "$update_f" stagit-index -cd /git &amp;&amp; stagit-index *.git &gt; /git/index.html &amp;&amp; is_ok - -# Errors but works -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 +<h2>Final Hook code (deploy, stagit, …)</h2> +<p>This can be seen in my <a href="/git/utils">/git/utils</a> repo, in the <code>git-hooks</code> folder.</p> +<p>Also the blog is a symlink to <code>/git/blog.work</code> which are the raw files done by that hook.</p> </code></pre>