logo

blog

My little blog can’t be this cute! git clone https://hacktivis.me/git/blog.git
commit: e83b6f3cafe31196ee215383131ab42b18cb7cc4
parent 38dfa8ba7eff016fb1bdedda327080b6f6b2ce6f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun,  2 Apr 2017 13:19:31 +0200

articles: Git serveur documentation

Diffstat:

Aarticles/My git server setup.html38++++++++++++++++++++++++++++++++++++++
Aarticles/My git server setup.shtml16++++++++++++++++
Aarticles/Paramétrage de mon serveur git.html38++++++++++++++++++++++++++++++++++++++
Aarticles/Paramétrage de mon serveur git.shtml16++++++++++++++++
4 files changed, 108 insertions(+), 0 deletions(-)

diff --git a/articles/My git server setup.html b/articles/My git server setup.html @@ -0,0 +1,38 @@ +<h1>My git server setup</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> +<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> +<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 +<pre><code>repo=$(pwd) +cd "$(pwd | sed s/.git$//)" &amp;&amp; stagit -c "$repo.cache" "$repo" +cd /git &amp;&amp; stagit-index *.git &lt; /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 &lt; /git/index.html &amp;&amp; is_ok + +# Errors but works +grep blog &gt;&gt;&gt;$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 +</code></pre> diff --git a/articles/My git server setup.shtml b/articles/My git server setup.shtml @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html lang="en"> + <head> +<!--#include file="/templates/head.shtml" --> + <title>My git server setup — Cyber-home of lanodan</title> + <link type="application/rss+xml" href="/rss" title="flux RSS" rel="alternate"></link> + </head> + <body> +<!--#include file="/templates/en/nav.shtml" --> + <article> +<!--#include file="/articles/My git server setup.html"--> + </article> + <a href="/articles/My%20git%20server%20setup.html">article only(plain HTML)</a> +<!--#include file="/templates/en/footer.html" --> + </body> +</html> diff --git a/articles/Paramétrage de mon serveur git.html b/articles/Paramétrage de mon serveur git.html @@ -0,0 +1,38 @@ +<h1>Paramétrage de mon serveur git</h1> +<p>Après avoir eu plusieurs problèmes avec gitlab.com (impossibilitée de <code>git push</code> sur mon propre dépot, par example). J’ai décidé de faire un truc simple, inspiré de git.linkmauve.fr. J’ai mis tout mes dépots git dans le <code>/git</code> +<h2>Démarrage avec juste nginx et ssh</h2> +<p>Celui-là est trivial quand on connais le truc, suffit de mettre <code>git update-server-info</code> dans <code>hooks/post-update</code> du dépot git (qui doit être un --bare)</p> +<h2>Ajout de git-daemon</h2> +<P>Celui-là fût encore plus simple, j’ai juste eu à dire où sont les dépots git</p> +<h2>Une meilleure interface</h2> +<p>En cherchant des alternatives au GNU je suis tombé sur <a href="http://git.2f30.org/stagit/">stagit</a>, un générateur static pour git (je n’aime pas les CGI, surtout quand ça peut avoir un accès sur mon dépot git), pour l’utiliser j’ai rajouté ces lines au post-update-hook :</p> +<pre><code>repo=$(pwd) +cd "$(pwd | sed s/.git$//)" &amp;&amp; stagit -c "$repo.cache" "$repo" +cd /git &amp;&amp; stagit-index *.git &lt; /git/index.html</code></pre></p> +<h2>Déployement vers blog</h2> +<p>Celui-là sort une erreur(probablement parceque GIT_INDEX_FILE est pas censé être vide) mais ça fonctionne :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>Ce n’est pas comme si mes dépots étaient gros, git est censé faire ça tout-seul mais apparement non, donc je fait un <code>git gc</code> à chaque fois, ce qui n’est pas très optimisé.</p> +<h2>post-update hook final</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 &lt; /git/index.html &amp;&amp; is_ok + +# Erreurs mais fonctionnel +grep blog &gt;&gt;&gt;$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 +</code></pre> diff --git a/articles/Paramétrage de mon serveur git.shtml b/articles/Paramétrage de mon serveur git.shtml @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html lang="fr"> + <head> +<!--#include file="/templates/head.shtml" --> + <title>Paramétrage de mon serveur git — Cyber-habitat de lanodan</title> + <link type="application/rss+xml" href="/rss" title="flux RSS" rel="alternate"> + </head> + <body> +<!--#include file="/templates/fr/nav.shtml" --> + <article> +<!--#include file="/articles/Paramétrage de mon serveur git.html"--> + </article> + <a href="/articles/Paramétrage%20de%20mon%20serveur%20git.html">article seul(HTML-brut)</a> +<!--#include file="/templates/fr/footer.html" --> + </body> +</html>