~rbdr/gemlog

5004875e70798f89177d23cadbc8efc7739f4143 — Ruben Beltran del Rio 2 months ago afc80ca
blog-sync-up-1707912360442
9 files changed, 28 insertions(+), 76 deletions(-)

A archive/1707912360364/geography.gmi
A archive/1707912360364/metadata.json
A posts/0/geography.gmi
M posts/0/metadata.json
R posts/{0/how-i-publish-my-website-using-page-and-sourcehut.gmi => 1/how-i-publish-my-website-using-page-and-sourcehut.gmi}
M posts/1/metadata.json
M posts/2/metadata.json
D posts/2/scripts-for-git-admin.gmi
R posts/{1/setting-up-net-on-se30.gmi => 2/setting-up-net-on-se30.gmi}
A archive/1707912360364/geography.gmi => archive/1707912360364/geography.gmi +9 -0
@@ 0,0 1,9 @@
# Geography

Every morning I walk towards the Bösebrücke and notice the cluster of birds arranging themselves in the shape of various countries as they eat the bugs in the sky.

Uruguay! *chomp* Laos! *chomp chomp* Benin! *chomp chomp chomp*.

Sometimes I don't recognize the country, so I have to look it up on the map: That was Georgia. (ah) That was Oman. (ah ah) That was Panama. (ah ah ah)

This is the way I've learned Geography.

A archive/1707912360364/metadata.json => archive/1707912360364/metadata.json +4 -0
@@ 0,0 1,4 @@
{
  "id": "1707912360364",
  "createdOn": 1707912360364
}
\ No newline at end of file

A posts/0/geography.gmi => posts/0/geography.gmi +9 -0
@@ 0,0 1,9 @@
# Geography

Every morning I walk towards the Bösebrücke and notice the cluster of birds arranging themselves in the shape of various countries as they eat the bugs in the sky.

Uruguay! *chomp* Laos! *chomp chomp* Benin! *chomp chomp chomp*.

Sometimes I don't recognize the country, so I have to look it up on the map: That was Georgia. (ah) That was Oman. (ah ah) That was Panama. (ah ah ah)

This is the way I've learned Geography.

M posts/0/metadata.json => posts/0/metadata.json +2 -2
@@ 1,4 1,4 @@
{
  "id": "1707084701399",
  "createdOn": 1707084701399
  "id": "1707912360364",
  "createdOn": 1707912360364
}
\ No newline at end of file

R posts/0/how-i-publish-my-website-using-page-and-sourcehut.gmi => posts/1/how-i-publish-my-website-using-page-and-sourcehut.gmi +0 -0
M posts/1/metadata.json => posts/1/metadata.json +2 -2
@@ 1,4 1,4 @@
{
  "id": "1706113636109",
  "createdOn": 1706113636109
  "id": "1707084701399",
  "createdOn": 1707084701399
}
\ No newline at end of file

M posts/2/metadata.json => posts/2/metadata.json +2 -2
@@ 1,4 1,4 @@
{
  "id": "1705848860112",
  "createdOn": 1705848860112
  "id": "1706113636109",
  "createdOn": 1706113636109
}
\ No newline at end of file

D posts/2/scripts-for-git-admin.gmi => posts/2/scripts-for-git-admin.gmi +0 -70
@@ 1,70 0,0 @@
# 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.

=> https://git.unlimited.pizza [1] git @ unlimited.pizza (https)
=> gemini://gemini.unlimited.pizza/git [2] git @ unlimited.pizza (gemini)
=> https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb [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
```

=> https://en.wikipedia.org/wiki/Rio_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!

R posts/1/setting-up-net-on-se30.gmi => posts/2/setting-up-net-on-se30.gmi +0 -0