Compare commits

..

No commits in common. "cb75558724d7d014be5a51a5adcbcf327df5d019" and "d44851b25a79ea0b9a075ce885ab1cc7e665f8fc" have entirely different histories.

2 changed files with 8 additions and 7 deletions

View file

@ -1,5 +1,5 @@
# ============================================================================= # =============================================================================
# Knowledge Genome - Makefile v. 1.6.0 # Knowledge Genome - Makefile v. 1.5.1
# Orchestrates the setup and management of the knowledge base. # Orchestrates the setup and management of the knowledge base.
# ============================================================================= # =============================================================================

View file

@ -6,6 +6,7 @@
# - One commit per author (single-device => one commit). No-op if there is nothing. # - One commit per author (single-device => one commit). No-op if there is nothing.
# - JSON output built with jq (safe escaping), with a `files` array: # - JSON output built with jq (safe escaping), with a `files` array:
# for each raw -> file, author, local_path, local_url (file://), remote_url (Forgejo web). # for each raw -> file, author, local_path, local_url (file://), remote_url (Forgejo web).
set -euo pipefail set -euo pipefail
genome="${1:?usage: genome-raw-commit <genome>}" genome="${1:?usage: genome-raw-commit <genome>}"
@ -18,7 +19,7 @@ set -a; . "${HOME}/.config/knowledge-genome.env"; set +a
: "${FORGEJO_USER:=n8n-bot}" : "${FORGEJO_USER:=n8n-bot}"
: "${FORGEJO_HOST:=127.0.0.1:3001}" : "${FORGEJO_HOST:=127.0.0.1:3001}"
: "${FORGEJO_OWNER:=Keru}" : "${FORGEJO_OWNER:=Keru}"
: "${FORGEJO_WEB_BASE:=https://git.keruhomelab.com}" # human-facing URL for remote links (not the loopback) : "${FORGEJO_WEB_BASE:=https://git.keruhomelab.com}
: "${SYNCTHING_URL:=http://127.0.0.1:8384}" : "${SYNCTHING_URL:=http://127.0.0.1:8384}"
: "${COMMITTER_NAME:=n8n-bot}" : "${COMMITTER_NAME:=n8n-bot}"
: "${COMMITTER_EMAIL:=n8n-bot@homelab}" : "${COMMITTER_EMAIL:=n8n-bot@homelab}"
@ -47,13 +48,13 @@ if git diff --cached --quiet; then
exit 0 exit 0
fi fi
resolve_dev() { # $1 = path relative to the vault (raw/...) -> prints the short device id, or empty resolve_dev() { # $1 = path relativo al vault (raw/...) -> stampa lo short device id o vuoto
[[ -z "${SYNCTHING_API_KEY:-}" ]] && return 0 [[ -z "${SYNCTHING_API_KEY:-}" ]] && return 0
curl -fsS -H "X-API-Key: ${SYNCTHING_API_KEY}" --get "${SYNCTHING_URL}/rest/db/file" \ curl -fsS -H "X-API-Key: ${SYNCTHING_API_KEY}" --get "${SYNCTHING_URL}/rest/db/file" \
--data-urlencode "folder=${fid}" --data-urlencode "file=${1#raw/}" 2>/dev/null \ --data-urlencode "folder=${fid}" --data-urlencode "file=${1#raw/}" 2>/dev/null \
| jq -r '.local.modifiedBy // empty' 2>/dev/null || true | jq -r '.local.modifiedBy // empty' 2>/dev/null || true
} }
author_for_dev() { # $1 = device id -> prints "name\temail" author_for_dev() { # $1 = device id -> stampa "name\temail"
local dev="$1" name="$DEFAULT_AUTHOR_NAME" email="$DEFAULT_AUTHOR_EMAIL" local dev="$1" name="$DEFAULT_AUTHOR_NAME" email="$DEFAULT_AUTHOR_EMAIL"
if [[ -n "$dev" && -f "$authors_map" ]] && jq -e --arg d "$dev" '.[$d]' "$authors_map" >/dev/null 2>&1; then if [[ -n "$dev" && -f "$authors_map" ]] && jq -e --arg d "$dev" '.[$d]' "$authors_map" >/dev/null 2>&1; then
name="$(jq -r --arg d "$dev" '.[$d].name' "$authors_map")" name="$(jq -r --arg d "$dev" '.[$d].name' "$authors_map")"
@ -62,7 +63,7 @@ author_for_dev() { # $1 = device id -> prints "name\temail"
printf '%s\t%s' "$name" "$email" printf '%s\t%s' "$name" "$email"
} }
# Collect per-file (relpath, author) and group by author for committing # raccolgo per-file (relpath, author) e raggruppo per autore per il commit
declare -A G_FILES G_NAME G_EMAIL declare -A G_FILES G_NAME G_EMAIL
declare -a ROWS declare -a ROWS
while IFS= read -r f; do while IFS= read -r f; do
@ -87,7 +88,7 @@ for key in "${!G_FILES[@]}"; do
summary="${summary}${summary:+; }${G_NAME[$key]}:${short}" summary="${summary}${summary:+; }${G_NAME[$key]}:${short}"
done done
# Pull in any remote advances (e.g. a merged wiki PR), then push # incorporo eventuali avanzamenti del remoto (es. PR wiki mergiata), poi pusho
git fetch -q origin git fetch -q origin
if git show-ref --verify --quiet "refs/remotes/origin/${GENOME_BASE}"; then if git show-ref --verify --quiet "refs/remotes/origin/${GENOME_BASE}"; then
git rebase -q "origin/${GENOME_BASE}" \ git rebase -q "origin/${GENOME_BASE}" \
@ -96,7 +97,7 @@ fi
git push -q "$clone_url" "HEAD:${GENOME_BASE}" git push -q "$clone_url" "HEAD:${GENOME_BASE}"
head="$(git rev-parse --short HEAD)" head="$(git rev-parse --short HEAD)"
# `files` array: local (file://) and remote (Forgejo web) link for each committed raw # array `files`: link locale (file://) e remoto (Forgejo web) per ogni raw committata
files_json="$( files_json="$(
for row in "${ROWS[@]}"; do for row in "${ROWS[@]}"; do
IFS=$'\t' read -r rel aname <<< "$row" IFS=$'\t' read -r rel aname <<< "$row"