-- Leo's gemini proxy

-- Connecting to r.bdr.sh:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; lang=en

Scripts for self-hosted git admin


Recently I've been using my own git server [1,2] to host my repositories, and for simplicity I decided to go with GitWeb [3]. This also means that I don't get a web management UI, which turns out is a great thing with a few helper scripts.


[1] git @ unlimited.pizza (https)

[2] git @ unlimited.pizza (gemini)

[3] GitWeb


repo_name to fetch repository name


I want to use the same <username>/<repo> structure across services, and this utility helps me extract it. It fetches the push origin remote, grabs the last two fragments of the URL and then removes any leading tilde (for compatibility with sourcehut). I don't really use this one directly, but all other scripts depend on it.


function repo_name {
  git remote -v | grep origin | grep push | grep -o '[^:/]\+\/[^/]\+\s\+' | grep -o '[^~:]\+\/[^ ]\+'
}

sync_to_conchos creates the repository


My upstream is called conchos [4], and this function checks if the origin exists and then pushes everything. The server is setup to create a private repository if it's not found.


function sync_to_conchos {
  if git config remote.conchos.url > /dev/null; then; else
    git remote add conchos "git@git.unlimited.pizza:$(repo_name)"
  fi
  git push conchos --all
  git push conchos --tags
}

// eg.
% cd ~/projects/web/blog && sync_to_conchos

[4] Rio Conchos


make_public /make_private control a repo's visibility


The git daemon controls public access with a file called `git-daemon-export-ok`, so controlling visibilitiy is as easy as touching or removing a file. If I run these from the root of the project, it controls its visibility.


function make_public {
  ssh git@git.unlimited.pizza -T "touch /srv/git/$(repo_name)/git-daemon-export-ok"
}

function make_private {
  ssh git@git.unlimited.pizza -T "rm /srv/git/$(repo_name)/git-daemon-export-ok"
}

// eg.
% cd ~/projects/web/blog && make_public

describe adds a description for the repo


The git daemon uses a file called `description` to show a description on the web.


function describe {
  ssh git@git.unlimited.pizza -T "echo '$1' > /srv/git/$(repo_name)/description"
}

// eg.
% cd ~/projects/web/blog && describe 'An (almost) ephemeral blog #cli'

That's it!


This has made managing my repositories a lot easier as I don't have to fiddle with a web UI at all. If you're also self-hosting git, maybe you'll also find them helpful!

-- Response ended

-- Page fetched on Mon May 20 19:09:12 2024