From 738e622fdcd86207f8d72ab957963aba77579d3b Mon Sep 17 00:00:00 2001 From: Michael Wolf Date: Sat, 7 Feb 2026 09:36:20 -0500 Subject: [PATCH] Add bootstrap and cached repository scripts bootstrap.sh clones from a local mirror and extracts framework files into the working directory. update-cached-repository.sh maintains the mirror under ~/.cache/diachron/v1/repositories/. Co-Authored-By: Claude Opus 4.6 --- bootstrap.sh | 47 +++++++++++++++++++++++++++++++++++++ update-cached-repository.sh | 22 +++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100755 bootstrap.sh create mode 100755 update-cached-repository.sh diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..ad58f80 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# shellcheck disable=SC2002 + +set -eu +set -o pipefail +IFS=$'\n\t' + +# print useful message on failure +trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR + +# shellcheck disable=SC2034 +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# cd "$DIR" +here="$PWD" + +"$DIR/update-cached-repository.sh" + +# repository="${2:-https://gitea.philologue.net/philologue/diachron}" +repository="${2:-$HOME/.cache/diachron/v1/repositories/diachron.git}" +ref="${1:-hydrators-kysely}" + +echo will bootstrap ref "$ref" of repo "$repository" + +into=$(mktemp -d) +cd "$into" +echo I am in $(pwd) +echo I will clone repository "$repository", ref "$ref" +git clone "$repository" + +r=$(ls -1) + +cd "$r" + +echo I am in $(pwd) + +git checkout "$ref" + +ls +echo working dir: $PWD +# ls backend + +# exit 0 + +tar cvf - $(cat "$PWD/file-list" | grep -v '^#') | (cd "$here" && tar xvf -) + +echo "$ref" > .diachron-version diff --git a/update-cached-repository.sh b/update-cached-repository.sh new file mode 100755 index 0000000..5a625bc --- /dev/null +++ b/update-cached-repository.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -eu +set -o pipefail +IFS=$'\n\t' + +trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR + +upstream=https://gitea.philologue.net/philologue/diachron +cache_dir="$HOME/.cache/diachron/v1/repositories" +cached_repo="$cache_dir/diachron.git" + +mkdir -p "$cache_dir" + +if [ -d "$cached_repo" ]; then + echo "Updating cached repository..." + git -C "$cached_repo" fetch --prune origin +else + echo "Creating cached repository..." + git clone --mirror "$upstream" "$cached_repo" +fi +