From 75a4fcbb3e220c2154044d966d5f8de2eeb96014 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 28 May 2023 22:14:04 -0500 Subject: Initial commit --- git-init-remote | 33 +++++++++++++++++++++++++++++++++ post-update.hook | 15 +++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 git-init-remote create mode 100755 post-update.hook diff --git a/git-init-remote b/git-init-remote new file mode 100755 index 0000000..4d8cb29 --- /dev/null +++ b/git-init-remote @@ -0,0 +1,33 @@ +#!/bin/sh + +GITREMOTE=git.acdw.net +GITROOT=/git + +git ls-files > /dev/null || exit 1 + +# consider --git-dir as well .. however --git-dir would require more massaging +# of the output. +local="$(git rev-parse --show-toplevel)" +name="${local##*/}" + +remote="$GITROOT/$name.git" + +## Remote work + +# Initiate the repository +echo "ssh \"$GITREMOTE\" git init --bare \"$remote\"" +ssh "$GITREMOTE" git init --bare "$remote" + +# Add a description +echo -n "Repo description: "; read +echo "ssh \"$GITREMOTE\" sh -c \"echo '$REPLY' > '$remote'\"" +ssh "$GITREMOTE" sh -c "echo '$REPLY' > '$remote'" + +# Add post-update-hook +echo "scp post-update.hook \"$GITREMOTE:$remote/hooks/post-update\"" +scp post-update.hook "$GITREMOTE:$remote/hooks/post-update" + +## Local work + +echo "git remote add origin \"$GITREMOTE:$remote\"" +git remote add origin "$GITREMOTE:$remote" diff --git a/post-update.hook b/post-update.hook new file mode 100755 index 0000000..a68bf65 --- /dev/null +++ b/post-update.hook @@ -0,0 +1,15 @@ +#!/bin/sh + +# Update "agefile" for cgit +# The default location is /info/web/last-modified + +agefile="$(git rev-parse --git-dir)/info/web/last-modified" +mkdir -p "$(dirname "$agefile")" + +git for-each-ref > "$agefile" \ + --sort=-authordate --count=1 \ + --format='%(authordate:iso8601)' + +# Prepare a packed repository for use over dumb transports + +git update-server-info -- cgit 1.4.1-21-gabe81