From 366df8852f503523cc4f9046d82ba9a99dd51d7f Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 12 Feb 2023 12:13:49 +0530 Subject: new art: lapse --- docs/posts/self-hosting_git/index.html | 67 ++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 15 deletions(-) (limited to 'docs/posts/self-hosting_git/index.html') diff --git a/docs/posts/self-hosting_git/index.html b/docs/posts/self-hosting_git/index.html index f41a591..d927e95 100644 --- a/docs/posts/self-hosting_git/index.html +++ b/docs/posts/self-hosting_git/index.html @@ -28,7 +28,7 @@ 17/10 — 2020
- 87.90 + 87.91 cm   @@ -42,11 +42,21 @@ Self-hosting Git
-

Earlier this week, I began migrating my repositories from Github to cgit. If you care at all about big corporates turning open-source into a T-shirt farming service, this is the way to go.

+

Earlier this week, I began migrating my repositories from Github to +cgit. If you care at all +about big corporates turning open-source into a T-shirt farming service, +this is the way to go.

Offerings

-

cgit is very bare bones. It is cgi-based web interface to git, and nothing more. You may browse repositories, view diffs, commit logs and even clone via http. If you are looking to replace Github with cgit, keep in mind that cgit does not handle issues or pull/merge requests. If people wish to contribute to your work, they would have to send you a patch via email.

+

cgit is very bare bones. It is cgi-based web interface +to git, and nothing more. You may browse repositories, view diffs, +commit logs and even clone via http. If you are looking to replace +Github with cgit, keep in mind that cgit does not handle issues or +pull/merge requests. If people wish to contribute to your work, they +would have to send you a patch via email.

Setup

-

Installing cgit is fairly straightforward, if you would like to compile it from source:

+

Installing cgit is fairly straightforward, if you would like to +compile it from source:

# fetch
 git clone https://git.zx2c4.com && cd cgit
 git submodule init
@@ -55,9 +65,16 @@
 # install
 make NO_LUA=1
 sudo make install
-

This would drop the cgit cgi script (and the default css) into /var/www/htdocs/cgit. You may configure cgit by editing /etc/cgitrc. I specify the NO_LUA flag to compile without lua support, exclude that flag if you would like to extend cgit via lua scripts.

+

This would drop the cgit cgi script (and the default css) into +/var/www/htdocs/cgit. You may configure cgit by editing +/etc/cgitrc. I specify the NO_LUA flag to +compile without lua support, exclude that flag if you would like to +extend cgit via lua scripts.

Going live

-

You might want to use, fcgiwrap, a fastcgi wrapper for cgi scripts,

+

You might want to use, fcgiwrap, a fastcgi wrapper for +cgi scripts,

sudo apt install fcgiwrap
 sudo systemctl start fcgiwrap.socket

Expose the cgit cgi script to the web via nginx:

@@ -81,15 +98,21 @@ server {

Point cgit to your git repositories:

# /etc/cgitrc
 scan-path=/path/to/git/repos
-

Note: scan-path works best if you stick it at the end of your cgitrc.

-

You may now create remote repositories at /path/to/git/repos, via:

+

Note: scan-path works best +if you stick it at the end of your cgitrc.

+

You may now create remote repositories at +/path/to/git/repos, via:

git init --bare

Add the remote to your local repository:

git remote set-url origin user@remote:/above/path
 git push origin master

Configuration

-

cgit is fairly easy to configure, all configuration options can be found in the manual, here are a couple of cool ones though:

-

enable-commit-graph: Generates a text based graphical representation of the commit history, similar to git log --graph --oneline.

+

cgit is fairly easy to configure, all configuration options can be +found in the +manual, here are a couple of cool ones though:

+

enable-commit-graph: Generates a text based +graphical representation of the commit history, similar to +git log --graph --oneline.

| * |    Add support for configuration file
 * | |    simplify command parsing logic
 * | |    Refactor parsers
@@ -110,7 +133,11 @@ git push origin master
| | * | Merge branch 'fix/duplicate-habits' | | |\ \ | | | * | move duplicate check to command parsing blo... -

section-from-path: This option paired with scan-path will automatically generate sections in your cgit index page, from the path to each repo. For example, the directory structure used to generate sections on my cgit instance looks like this:

+

section-from-path: This option paired with +scan-path will automatically generate sections in your cgit +index page, from the path to each repo. For example, the directory +structure used to generate sections on my +cgit instance looks like this:

├── cli
 │   ├── dijo
 │   ├── eva
@@ -134,11 +161,18 @@ git push origin master
└── web └── isostatic

Ease of use

-

As I mentioned before, cgit is simply a view into your git repositories, you will have to manually create new repositories by entering your remote and using git init --bare. Here are a couple of scripts I wrote to perform actions on remotes, think of it as a smaller version of Github’s gh program.

-

You may save these scripts as git-script-name and drop them in your $PATH, and git will automatically add an alias called script-name, callable via:

+

As I mentioned before, cgit is simply a view into your +git repositories, you will have to manually create new repositories by +entering your remote and using git init --bare. Here are a +couple of scripts I wrote to perform actions on remotes, think of it as +a smaller version of Github’s gh program.

+

You may save these scripts as git-script-name and drop +them in your $PATH, and git will automatically add an alias +called script-name, callable via:

git script-name

git-new-repo

-

Creates a new repository on your remote, the first arg may be a path (section/repo-name) or just the repo name:

+

Creates a new repository on your remote, the first arg may be a path +(section/repo-name) or just the repo name:

#! /usr/bin/env bash
 #
 # usage:
@@ -155,7 +189,10 @@ fi
 
 ssh user@remote git init --bare "$1";

git-set-desc

-

To set a one line repository description. It simply copies the local .git/description, into remote/description. cgit displays the contents of this file on the index page:

+

To set a one line repository description. It simply copies the local +.git/description, into remote/description. +cgit displays the contents of this file on the index +page:

#! /usr/bin/env bash
 #
 # usage:
-- 
cgit v1.2.3