2018-10-13 cgit

@aminb asked my about my cgit setup.

@aminb

This is `/etc/cgitrc`:

# cgit config
# see cgitrc(5) for details

css=/cgit-css/cgit.css
logo=https://alexschroeder.ch/pics/alex-and-beard-80x80.jpg
root-title=Git repositories
root-desc=Code repositories hosted by Alex Schroeder
root-readme=/home/git/root.html
readme=master:README.md
readme=master:README
about-filter=/usr/lib/cgit/filters/about-formatting.sh

source-filter=/usr/lib/cgit/filters/syntax-highlighting-or-markdown.py

clone-prefix=https://alexschroeder.ch/cgit

remove-suffix=1
enable-index-owner=0
scan-path=/home/git

This means that the `/cgit` path from all my virtual servers is going to end up serving `cgit`. I don’t mind.

The `/home/git` directory has all my repositories:

drwxr-xr-x 24 git  git  4096 Sep 13 23:14 .
drwxr-xr-x  4 root root 4096 Apr 20 15:20 ..
-rw-------  1 git  git   146 Apr 20 15:27 .bash_history
-rw-r--r--  1 git  git   220 Apr 20 15:20 .bash_logout
-rw-r--r--  1 git  git  3526 Apr 20 15:20 .bashrc
drwxrwsr-x  7 git  git  4096 Sep 10 10:38 bitlbee-mastodon.git
drwxrwsr-x  7 git  git  4096 Jun 21 11:10 character-sheet-generator.git
drwxrwsr-x  7 git  git  4096 Sep 14 23:41 emacs-setup.git
drwxrwsr-x  7 git  git  4096 Jun 21 11:10 face-generator.git
-rw-r--r--  1 git  git    39 Jun 21 11:07 .gitconfig
drwxrwsr-x  7 git  git  4096 Jun 21 11:10 gridmapper.git
drwxrwsr-x  7 git  git  4096 Jul 20 00:12 halberds-and-helmets.git
drwxrwsr-x  7 git  git  4096 Jun 21 11:10 hellebarden-und-helme.git
drwxr-xr-x  7 git  git  4096 Jun 25 14:50 hex-mapping.git
drwxrwsr-x  7 git  git  4096 Oct  8 23:26 mastodon-archive.git
drwxrwsr-x  7 git  git  4096 Sep 17 07:42 mastodon-blocker.git
drwxrwsr-x  7 git  git  4096 Jul 16 15:34 moku-pona.git
drwxrwsr-x  7 git  git  4096 Jul 24 15:50 mu.git
drwxrwsr-x  7 git  git  4096 Sep 13 18:08 oddmu.git
drwxrwsr-x  7 git  git  4096 Oct  7 20:54 oddmuse6.git
drwxrwsr-x  7 git  git  4096 Oct  7 18:15 oddmuse.git
-rw-r--r--  1 git  git   675 Apr 20 15:20 .profile
drwxrwsr-x  7 git  git  4096 Aug 30 23:52 qmk_firmware.git
-rw-r--r--  1 root root  122 Jun  4 08:44 README
-rw-r--r--  1 root root   49 Jun  4 08:43 README~
-rw-r--r--  1 root root  494 Jun  9 00:36 root.html
-rw-r--r--  1 root root   14 Jun  9 00:30 root.html~
drwxrwsr-x  7 git  git  4096 Jul 17 13:57 sitelen-mute.git
drwxrwsr-x  7 git  git  4096 Jul 31 11:47 spellcasters.git
drwx------  2 git  git  4096 Jun 13 09:13 .ssh
drwxrwsr-x  7 git  git  4096 Sep 11 09:08 text-mapper-mastodon-bot.git
drwxrwsr-x  7 git  git  4096 Sep 18 11:59 trunk.git
drwxrwsr-x  7 git  git  4096 Aug 31 00:04 typing.git

Because I’m evil, the `.gitconfig` says:

[receive]
	denynonfastforwards = false

The `README` file says:

# https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server
mkdir project.git
cd project.git
git init --bare

My `root` user has a little script called `add-repo` which I have to run to create new projects:

#!/bin/bash

if [ -z $1 ]; then
    echo Must provide the name of a new repo
    exit 1
elif [ ! -z $2 ]; then
    echo Must provide just the name a new repo
    exit 1
elif [ -e $1 ]; then
    echo This file exists already
    exit 1
fi

# https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server

dir="/home/git/$1.git"
mkdir "$dir"
chown git.git "$dir"
(cd "$dir" && sudo -u git git init --bare --shared)
echo Provide description
read desc &&  echo $desc > "$dir/description"

Remember the `/etc/cgitrc` file also mentioned some scripts for formatting. `/usr/lib/cgit/filters/syntax-highlighting-or-markdown.py` is what I frankensteined together. See 2018-06-11 Highlighting Code and Rendering Markdown for cgit for more.

2018-06-11 Highlighting Code and Rendering Markdown for cgit

​#Administration ​#cgit

echo ref: refs/heads/main > /usr/share/git-core/templates/HEAD

mygit

@aw

Sadly, the “cargo” on my system cannot compile it. 😢

Rust up!

legit

Using legit for my repos