feat: Enhance output with detailed JSON including file URLs
This commit is contained in:
parent
e1a00d2db7
commit
726a1e2ed4
1 changed files with 19 additions and 5 deletions
|
|
@ -81,20 +81,34 @@ commits=0; summary=""
|
||||||
for key in "${!G_FILES[@]}"; do
|
for key in "${!G_FILES[@]}"; do
|
||||||
mapfile -t files < <(printf '%s' "${G_FILES[$key]}")
|
mapfile -t files < <(printf '%s' "${G_FILES[$key]}")
|
||||||
short="$(printf '%s\n' "${files[@]}" | sed 's#^raw/##' | paste -sd, -)"
|
short="$(printf '%s\n' "${files[@]}" | sed 's#^raw/##' | paste -sd, -)"
|
||||||
msg="$(printf 'raw(%s): sync %s\n\nAdded-by-device: %s\nSyncthing-device-id: %s\nSource: syncthing-autocommit\nSynced-at: %s\n' \
|
msg="$(printf 'raw(%s): sync %s\n\nAdded-by: %s\nSource: syncthing-autocommit\nSynced-at: %s\n' \
|
||||||
"$genome" "$short" "${G_DEV[$key]}" "${G_DEV[$key]}" "$ts")"
|
"$genome" "$short" "${G_NAME[$key]}" "$ts")"
|
||||||
git commit -q --author="$key" -m "$msg" -- "${files[@]}"
|
git commit -q --author="$key" -m "$msg" -- "${files[@]}"
|
||||||
commits=$((commits+1))
|
commits=$((commits+1))
|
||||||
summary="${summary}${summary:+; }${G_NAME[$key]}:${short}"
|
summary="${summary}${summary:+; }${G_NAME[$key]}:${short}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Fetch updates from origin to merge upstream modifications before pushing
|
# 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}" \
|
||||||
|| { git rebase --abort 2>/dev/null || true; printf '{"status":"error","reason":"rebase-conflict","genome":"%s"}\n' "$genome"; exit 1; }
|
|| { git rebase --abort 2>/dev/null || true; printf '{"status":"error","reason":"rebase-conflict","genome":"%s"}\n' "$genome"; exit 1; }
|
||||||
fi
|
fi
|
||||||
git push -q "$clone_url" "HEAD:${GENOME_BASE}"
|
git push -q "$clone_url" "HEAD:${GENOME_BASE}"
|
||||||
|
head="$(git rev-parse --short HEAD)"
|
||||||
|
|
||||||
printf '{"status":"ok","genome":"%s","base":"%s","commits":%d","head":"%s","summary":"%s"}\n' \
|
# array `files`: link locale (file://) e remoto (Forgejo web) per ogni raw committata
|
||||||
"$genome" "$GENOME_BASE" $commits "$(git rev-parse --short HEAD)" "$summary"
|
files_json="$(
|
||||||
|
for row in "${ROWS[@]}"; do
|
||||||
|
IFS=$'\t' read -r rel aname <<< "$row"
|
||||||
|
jq -n --arg file "$rel" --arg author "$aname" \
|
||||||
|
--arg lpath "${vault}/${rel}" \
|
||||||
|
--arg lurl "file://${vault}/${rel}" \
|
||||||
|
--arg rurl "${FORGEJO_WEB_BASE}/${FORGEJO_OWNER}/${genome}/src/branch/${GENOME_BASE}/${rel}" \
|
||||||
|
'{file:$file, author:$author, local_path:$lpath, local_url:$lurl, remote_url:$rurl}'
|
||||||
|
done | jq -s '.'
|
||||||
|
)"
|
||||||
|
|
||||||
|
jq -n --arg genome "$genome" --arg base "$GENOME_BASE" --argjson commits "$commits" \
|
||||||
|
--arg head "$head" --arg summary "$summary" --argjson files "$files_json" \
|
||||||
|
'{status:"ok", genome:$genome, base:$base, commits:$commits, head:$head, summary:$summary, files:$files}'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue