Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
117 lines
3.2 KiB
Bash
117 lines
3.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Add .git, .gitignore, and README.md to all project directories under PROJECTS_DIR that don't have .git;
|
|
# then run push-all-projects-to-gitea.sh to create Gitea repos and push.
|
|
# Usage: bash scripts/dev-vm/init-projects-git-and-push.sh [--dry-run] [--no-push]
|
|
# Optional: PROJECTS_DIR=/path
|
|
# Requires: run from proxmox repo root; GITEA_TOKEN in env or root .env for push
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
[ -f "$PROJECT_ROOT/.env" ] && set +u && source "$PROJECT_ROOT/.env" 2>/dev/null || true && set -u
|
|
|
|
PROJECTS_DIR="${PROJECTS_DIR:-/home/intlc/projects}"
|
|
DRY_RUN=false
|
|
NO_PUSH=false
|
|
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=true
|
|
[[ "${1:-}" == "--no-push" ]] && NO_PUSH=true
|
|
|
|
# Directories to skip (not treated as projects)
|
|
SKIP_NAMES=(
|
|
__pycache__
|
|
archives
|
|
logs
|
|
.git
|
|
)
|
|
|
|
# Default .gitignore content (multi-language)
|
|
GITIGNORE_TEMPLATE="$SCRIPT_DIR/gitignore-default.txt"
|
|
|
|
discover_no_git_dirs() {
|
|
for d in "$PROJECTS_DIR"/*/; do
|
|
[ -d "${d}.git" ] && continue
|
|
name=$(basename "$d")
|
|
for skip in "${SKIP_NAMES[@]}"; do
|
|
[[ "$name" == "$skip" ]] && continue 2
|
|
done
|
|
echo "$d"
|
|
done 2>/dev/null | sort -u
|
|
}
|
|
|
|
ensure_gitignore() {
|
|
local dir="$1"
|
|
if [ -f "$dir/.gitignore" ]; then
|
|
return 0
|
|
fi
|
|
if [ -f "$GITIGNORE_TEMPLATE" ]; then
|
|
cp "$GITIGNORE_TEMPLATE" "$dir/.gitignore"
|
|
echo " Added .gitignore"
|
|
else
|
|
printf '# Dependencies\nnode_modules/\n# Env\n.env\n.env.*\n# OS\n.DS_Store\n# Build\ndist/\nbuild/\n' > "$dir/.gitignore"
|
|
echo " Added minimal .gitignore"
|
|
fi
|
|
}
|
|
|
|
ensure_readme() {
|
|
local dir="$1"
|
|
local name="$2"
|
|
if [ -f "$dir/README.md" ]; then
|
|
return 0
|
|
fi
|
|
cat > "$dir/README.md" << EOF
|
|
# $name
|
|
|
|
Project under \`$PROJECTS_DIR/$name\`.
|
|
|
|
## Overview
|
|
|
|
(Add project description and setup instructions here.)
|
|
EOF
|
|
echo " Added README.md"
|
|
}
|
|
|
|
init_and_commit() {
|
|
local dir="$1"
|
|
local name="$2"
|
|
if $DRY_RUN; then
|
|
echo " [DRY-RUN] Would: git init, add .gitignore, README.md, initial commit"
|
|
return 0
|
|
fi
|
|
(cd "$dir" && git init -b main 2>/dev/null) || (cd "$dir" && git init && git branch -M main)
|
|
ensure_gitignore "$dir"
|
|
ensure_readme "$dir" "$name"
|
|
(cd "$dir" && git add -A && git status --short)
|
|
if (cd "$dir" && git diff --cached --quiet); then
|
|
echo " No changes to commit (already tracked or empty)"
|
|
else
|
|
(cd "$dir" && git commit -m "Initial commit: add .gitignore and README")
|
|
echo " Initial commit done"
|
|
fi
|
|
}
|
|
|
|
echo "Projects dir: $PROJECTS_DIR | DRY_RUN=$DRY_RUN | NO_PUSH=$NO_PUSH"
|
|
DIRS=()
|
|
while read -r d; do
|
|
[ -n "$d" ] && DIRS+=("$d")
|
|
done < <(discover_no_git_dirs)
|
|
|
|
echo "Found ${#DIRS[@]} directories without .git. Initializing..."
|
|
for d in "${DIRS[@]}"; do
|
|
name=$(basename "$d")
|
|
echo "--- $name ---"
|
|
init_and_commit "$d" "$name" || true
|
|
done
|
|
echo "Done initializing."
|
|
|
|
if [ "$NO_PUSH" = true ]; then
|
|
echo "Skipping push (--no-push). Run: bash scripts/dev-vm/push-all-projects-to-gitea.sh"
|
|
exit 0
|
|
fi
|
|
if $DRY_RUN; then
|
|
echo "Dry-run: skipping push. Run without --dry-run to push."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Running push-all-projects-to-gitea.sh..."
|
|
exec bash "$SCRIPT_DIR/push-all-projects-to-gitea.sh"
|