Compare commits
3 commits
5e8b72a04f
...
7570613289
| Author | SHA1 | Date | |
|---|---|---|---|
| 7570613289 | |||
| 418ca57dc3 | |||
| 49be5ada89 |
1 changed files with 6 additions and 7 deletions
|
|
@ -6,7 +6,6 @@
|
||||||
# - 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>}"
|
||||||
|
|
||||||
|
|
@ -19,7 +18,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}
|
: "${FORGEJO_WEB_BASE:=https://git.keruhomelab.com}" # human-facing URL for remote links (not the loopback)
|
||||||
: "${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}"
|
||||||
|
|
@ -48,13 +47,13 @@ if git diff --cached --quiet; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
resolve_dev() { # $1 = path relativo al vault (raw/...) -> stampa lo short device id o vuoto
|
resolve_dev() { # $1 = path relative to the vault (raw/...) -> prints the short device id, or empty
|
||||||
[[ -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 -> stampa "name\temail"
|
author_for_dev() { # $1 = device id -> prints "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")"
|
||||||
|
|
@ -63,7 +62,7 @@ author_for_dev() { # $1 = device id -> stampa "name\temail"
|
||||||
printf '%s\t%s' "$name" "$email"
|
printf '%s\t%s' "$name" "$email"
|
||||||
}
|
}
|
||||||
|
|
||||||
# raccolgo per-file (relpath, author) e raggruppo per autore per il commit
|
# Collect per-file (relpath, author) and group by author for committing
|
||||||
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
|
||||||
|
|
@ -88,7 +87,7 @@ for key in "${!G_FILES[@]}"; do
|
||||||
summary="${summary}${summary:+; }${G_NAME[$key]}:${short}"
|
summary="${summary}${summary:+; }${G_NAME[$key]}:${short}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# incorporo eventuali avanzamenti del remoto (es. PR wiki mergiata), poi pusho
|
# Pull in any remote advances (e.g. a merged wiki PR), then push
|
||||||
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}" \
|
||||||
|
|
@ -97,7 +96,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)"
|
||||||
|
|
||||||
# array `files`: link locale (file://) e remoto (Forgejo web) per ogni raw committata
|
# `files` array: local (file://) and remote (Forgejo web) link for each committed raw
|
||||||
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"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue