upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-01-23 14:26:54 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-01-27 20:38:02 +0000
commitb61d388162438d12df37aa3fcd40bc9d3344d5bd (patch)
treedeb76a13e3f4bc7098301d0194db1c3ca6672039
parent79d2d01923cf66217fd5aa3a0be5ee9ea2000872 (diff)
Add git prerequisite checks to migration scripts
- 10-check-git-sync.sh: Check for git before running - run-migration-analysis.sh: Include git in prerequisite checks - Fixes script failures when git is not installed
-rwxr-xr-xdocs/how-to/migration-scripts/10-check-git-sync.sh15
-rwxr-xr-xdocs/how-to/migration-scripts/run-migration-analysis.sh4
2 files changed, 13 insertions, 6 deletions
diff --git a/docs/how-to/migration-scripts/10-check-git-sync.sh b/docs/how-to/migration-scripts/10-check-git-sync.sh
index 1f2ce04..b4536cb 100755
--- a/docs/how-to/migration-scripts/10-check-git-sync.sh
+++ b/docs/how-to/migration-scripts/10-check-git-sync.sh
@@ -118,6 +118,11 @@ usage() {
118check_prerequisites() { 118check_prerequisites() {
119 local missing=0 119 local missing=0
120 120
121 if ! command -v git &> /dev/null; then
122 log_error "git not found. Install with your package manager."
123 missing=1
124 fi
125
121 if ! command -v nak &> /dev/null; then 126 if ! command -v nak &> /dev/null; then
122 log_error "nak not found. Install from: https://github.com/fiatjaf/nak" 127 log_error "nak not found. Install from: https://github.com/fiatjaf/nak"
123 log_error "Or run: nix-shell -p nak jq --run \"$0 $*\"" 128 log_error "Or run: nix-shell -p nak jq --run \"$0 $*\""
@@ -161,13 +166,15 @@ count_git_refs() {
161 return 166 return
162 fi 167 fi
163 168
164 # Use git show-ref to handle both packed and loose refs 169 # Try git show-ref first (handles packed refs correctly)
165 # Fall back to counting loose refs if git show-ref fails 170 # Note: We capture output separately to avoid pipefail issues
166 if git --git-dir="$git_dir" show-ref --heads 2>/dev/null | wc -l | tr -d ' '; then 171 local count
172 if count=$(git --git-dir="$git_dir" show-ref --heads 2>/dev/null | wc -l); then
173 echo "$count" | tr -d ' '
167 return 174 return
168 fi 175 fi
169 176
170 # Fallback: count loose refs 177 # Fallback: count loose refs (when git is not available or fails)
171 if [[ -d "$git_dir/refs/heads" ]]; then 178 if [[ -d "$git_dir/refs/heads" ]]; then
172 find "$git_dir/refs/heads" -type f 2>/dev/null | wc -l | tr -d ' ' 179 find "$git_dir/refs/heads" -type f 2>/dev/null | wc -l | tr -d ' '
173 else 180 else
diff --git a/docs/how-to/migration-scripts/run-migration-analysis.sh b/docs/how-to/migration-scripts/run-migration-analysis.sh
index 84aec2a..65d9d17 100755
--- a/docs/how-to/migration-scripts/run-migration-analysis.sh
+++ b/docs/how-to/migration-scripts/run-migration-analysis.sh
@@ -155,7 +155,7 @@ FROM_PHASE=""
155declare -A PHASE_TIMES 155declare -A PHASE_TIMES
156 156
157usage() { 157usage() {
158 head -80 "$0" | tail -n +3 | sed 's/^# //' | sed 's/^#//' 158 head -73 "$0" | tail -n +3 | sed 's/^# //' | sed 's/^#//'
159 exit 0 159 exit 0
160} 160}
161 161
@@ -285,7 +285,7 @@ check_prerequisites() {
285 log_info "Checking prerequisites..." 285 log_info "Checking prerequisites..."
286 286
287 # Required tools 287 # Required tools
288 for tool in nak jq awk sort; do 288 for tool in git nak jq awk sort; do
289 if command -v "$tool" &> /dev/null; then 289 if command -v "$tool" &> /dev/null; then
290 log_step "$tool: found" 290 log_step "$tool: found"
291 else 291 else