interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / tools / ops / store-post-update

19 lines · 1422 bytes Raw Blame History
1#!/bin/sh
2# store-post-update: the post-update hook of every repository in the git store ~/git (nested folders
3# included). git runs it after every push to the store, and on the Spark every landing is such a push.
4# Installed once as ~/.local/lib/store-hooks/post-update; ~/.gitconfig points every repository under ~/git
5# at that folder (README, "Store hook"), so a repository created later gets it with no step of its own.
6# Never fails the push and never makes it wait:
7# 1. bazinga-git sync: refresh the public read-only copy of this repository (as the old per-repository hook did)
8# 2. spark-cleanup --landed NAME, detached: remove or archive the leftover working copies of this repository
9# 3. then disk-alarm --quiet: a board ALARM and a Linear comment if free space is short or falling fast
10n=$(basename "$(pwd)" .git)
11B=${STORE_HOOK_BIN:-$HOME/.local/bin}
12S=${STORE_HOOK_SYNC:-$HOME/.local/lib/bazinga-git/sync.sh}
13mkdir -p "$HOME/.local/state/bazinga-git" 2>/dev/null
14[ -x "$S" ] && "$S" "$n" >> "$HOME/.local/state/bazinga-git/sync.log" 2>&1
15# git sets GIT_DIR and friends for this hook; the steps below work on other repositories, so none may leak
16for v in $(env | sed -n 's/^\(GIT_[A-Za-z0-9_]*\)=.*/\1/p'); do unset "$v"; done
17( cd / && setsid nohup sh -c '"$1/spark-cleanup" --landed "$2"; "$1/disk-alarm" --quiet' store-post-update "$B" "$n" \
18 < /dev/null > /dev/null 2>&1 & ) 2>/dev/null
19exit 0