From fa5d7ead69fe58e2317ae803e25bc73069b1ec91 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Mon, 22 Dec 2025 18:26:31 +0100 Subject: add git readme command --- modules/git/default.nix | 5 ++--- modules/git/git-shell-commands/desc | 2 +- modules/git/git-shell-commands/help | 2 ++ modules/git/git-shell-commands/init | 3 ++- modules/git/git-shell-commands/owner | 2 +- modules/git/git-shell-commands/readme | 16 ++++++++++++++++ modules/git/git-shell-commands/section | 2 +- 7 files changed, 25 insertions(+), 7 deletions(-) create mode 100755 modules/git/git-shell-commands/readme diff --git a/modules/git/default.nix b/modules/git/default.nix index 0827735..914ff3e 100644 --- a/modules/git/default.nix +++ b/modules/git/default.nix @@ -85,9 +85,8 @@ }; system.activationScripts.setup-git-shell-commands.text = '' - if [[ ! -h "/var/lib/git/git-shell-commands" ]]; then - ln -s "${./git-shell-commands}" "/var/lib/git/git-shell-commands" - fi + rm "/var/lib/git/git-shell-commands" + ln -s "${./git-shell-commands}" "/var/lib/git/git-shell-commands" ''; services.nginx.virtualHosts = { diff --git a/modules/git/git-shell-commands/desc b/modules/git/git-shell-commands/desc index 52cc8bb..d81f46c 100755 --- a/modules/git/git-shell-commands/desc +++ b/modules/git/git-shell-commands/desc @@ -1,6 +1,6 @@ #!/usr/bin/env sh if [ -f "$1/config" ]; then - cd "$1" + cd "$1" || exit git config cgit.desc "$2" fi diff --git a/modules/git/git-shell-commands/help b/modules/git/git-shell-commands/help index 7572fe4..930d608 100755 --- a/modules/git/git-shell-commands/help +++ b/modules/git/git-shell-commands/help @@ -9,3 +9,5 @@ echo " owner " echo " Set repo owner" echo " section
" echo " Set repo section" +echo " readme [md|adoc]" +echo " Set readme format" diff --git a/modules/git/git-shell-commands/init b/modules/git/git-shell-commands/init index 603b817..557f20e 100755 --- a/modules/git/git-shell-commands/init +++ b/modules/git/git-shell-commands/init @@ -4,6 +4,7 @@ REPO="$1" if [ ! -f "$REPO/config" ]; then mkdir -p "$REPO" - cd "$REPO" + cd "$REPO" || exit git init --bare --shared + git config cgit.readme "main:README.md" fi diff --git a/modules/git/git-shell-commands/owner b/modules/git/git-shell-commands/owner index d65fd02..bd54e59 100755 --- a/modules/git/git-shell-commands/owner +++ b/modules/git/git-shell-commands/owner @@ -1,6 +1,6 @@ #!/usr/bin/env sh if [ -f "$1/config" ]; then - cd "$1" + cd "$1" || exit git config cgit.owner "$2" fi diff --git a/modules/git/git-shell-commands/readme b/modules/git/git-shell-commands/readme new file mode 100755 index 0000000..b3c34f7 --- /dev/null +++ b/modules/git/git-shell-commands/readme @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +if [ -f "$1/config" ]; then + cd "$1" || exit + case "$2" in + "md") + git config cgit.readme "main:README.md" + ;; + "adoc") + git config cgit.readme "main:README.adoc" + ;; + *) + echo "no idea what you're talking about. md | adoc" + ;; + esac +fi diff --git a/modules/git/git-shell-commands/section b/modules/git/git-shell-commands/section index b1a998e..e367a5e 100755 --- a/modules/git/git-shell-commands/section +++ b/modules/git/git-shell-commands/section @@ -1,6 +1,6 @@ #!/usr/bin/env sh if [ -f "$1/config" ]; then - cd "$1" + cd "$1" || exit git config cgit.section "$2" fi -- cgit v1.2.3