- scripts/copilot-update.sh: zieht Setup-Repo (SSH+HTTP-Fallback) in ~/.copilot-setup/, aktualisiert ~/.git-templates/, VS Code Prompts und repo-lokale Git-Hooks; copilot-instructions.md nur bei TODO-Erkennung (mit .bak Backup) - scripts/copilot-update.fish: Fish-Variante desselben Scripts - git-templates/hooks/post-merge: opt-in Template-Hook (ruft copilot-update.sh auf) - scripts/deploy.sh: installiert copilot-update.sh/.fish, setzt 'git copilot-update' Alias, installiert post-merge Hook im Setup-Repo selbst (auto-deploy nach git pull) - scripts/deploy.fish: analog - scripts/copilot-bootstrap.sh: --with-update-hook Flag + post-commit Hook Installation
151 lines
5.9 KiB
Fish
151 lines
5.9 KiB
Fish
#!/usr/bin/env fish
|
||
# copilot-update.fish
|
||
# Zieht die neueste Version des Copilot-Setup-Repos und aktualisiert:
|
||
# - Globale Git-Templates (~/.git-templates/)
|
||
# - VS Code Prompt-Dateien
|
||
# - Git-Hooks im aktuellen Repo (pre-commit, post-commit)
|
||
# - .github/copilot-instructions.md (nur wenn noch TODO-Platzhalter enthalten)
|
||
#
|
||
# Usage:
|
||
# fish ~/.local/bin/copilot-update.fish
|
||
# git copilot-update (via Alias, ruft copilot-update.sh auf)
|
||
|
||
set SETUP_REPO_SSH "ssh://git@192.168.178.6:2222/cschulz/rd13_copilot_setup.git"
|
||
set SETUP_REPO_HTTP "http://192.168.178.6:8083/cschulz/rd13_copilot_setup.git"
|
||
|
||
if set -q COPILOT_SETUP_DIR
|
||
set CACHE_DIR $COPILOT_SETUP_DIR
|
||
else
|
||
set CACHE_DIR $HOME/.copilot-setup
|
||
end
|
||
|
||
echo "=== Copilot Update ==="
|
||
|
||
# ── 1. Setup-Repo Cache aktuell halten ───────────────────────────────────────
|
||
if test -d $CACHE_DIR/.git
|
||
echo " → Pulling latest from setup repo..."
|
||
if git -C $CACHE_DIR pull --ff-only --quiet 2>/dev/null
|
||
echo " ✓ Cache aktualisiert: $CACHE_DIR"
|
||
else
|
||
echo " ✗ git pull fehlgeschlagen – versuche neu zu klonen..."
|
||
rm -rf $CACHE_DIR
|
||
end
|
||
end
|
||
|
||
if not test -d $CACHE_DIR/.git
|
||
echo " → Klone Setup-Repo (SSH)..."
|
||
if git clone --quiet $SETUP_REPO_SSH $CACHE_DIR 2>/dev/null
|
||
echo " ✓ Geklont via SSH"
|
||
else
|
||
echo " ✗ SSH fehlgeschlagen – versuche HTTP-Fallback..."
|
||
if git clone --quiet $SETUP_REPO_HTTP $CACHE_DIR 2>/dev/null
|
||
echo " ✓ Geklont via HTTP"
|
||
else
|
||
echo ""
|
||
echo " ✗ FEHLER: Setup-Repo nicht erreichbar."
|
||
echo " SSH: $SETUP_REPO_SSH"
|
||
echo " HTTP: $SETUP_REPO_HTTP"
|
||
exit 1
|
||
end
|
||
end
|
||
end
|
||
|
||
set SOURCE $CACHE_DIR
|
||
|
||
# ── 2. Globale Git-Templates aktualisieren ────────────────────────────────────
|
||
set GIT_TEMPLATE_DIR $HOME/.git-templates
|
||
mkdir -p $GIT_TEMPLATE_DIR/.github $GIT_TEMPLATE_DIR/.vscode \
|
||
$GIT_TEMPLATE_DIR/hooks $GIT_TEMPLATE_DIR/docs \
|
||
$GIT_TEMPLATE_DIR/history/summary
|
||
|
||
cp $SOURCE/git-templates/.github/copilot-instructions.md $GIT_TEMPLATE_DIR/.github/
|
||
cp $SOURCE/git-templates/.vscode/settings.json $GIT_TEMPLATE_DIR/.vscode/
|
||
cp $SOURCE/git-templates/.vscode/extensions.json $GIT_TEMPLATE_DIR/.vscode/
|
||
cp $SOURCE/git-templates/hooks/pre-commit $GIT_TEMPLATE_DIR/hooks/
|
||
cp $SOURCE/git-templates/hooks/post-commit $GIT_TEMPLATE_DIR/hooks/
|
||
chmod +x $GIT_TEMPLATE_DIR/hooks/pre-commit $GIT_TEMPLATE_DIR/hooks/post-commit
|
||
if test -f $SOURCE/git-templates/hooks/post-merge
|
||
cp $SOURCE/git-templates/hooks/post-merge $GIT_TEMPLATE_DIR/hooks/
|
||
chmod +x $GIT_TEMPLATE_DIR/hooks/post-merge
|
||
end
|
||
cp $SOURCE/git-templates/docs/USER.md $GIT_TEMPLATE_DIR/docs/
|
||
cp $SOURCE/git-templates/docs/ADMIN.md $GIT_TEMPLATE_DIR/docs/
|
||
cp $SOURCE/git-templates/docs/MAINTAINER.md $GIT_TEMPLATE_DIR/docs/
|
||
cp $SOURCE/git-templates/history/summary/PROJECT_CONTEXT.md $GIT_TEMPLATE_DIR/history/summary/
|
||
|
||
echo " ✓ ~/.git-templates/ aktualisiert"
|
||
|
||
# ── 3. VS Code Prompt-Dateien aktualisieren ───────────────────────────────────
|
||
if test -d $HOME/.vscode-server/data/User
|
||
set VSCODE_USER $HOME/.vscode-server/data/User
|
||
else if test -d "$HOME/Library/Application Support/Code/User"
|
||
set VSCODE_USER "$HOME/Library/Application Support/Code/User"
|
||
else
|
||
set VSCODE_USER $HOME/.config/Code/User
|
||
end
|
||
|
||
if test -d $VSCODE_USER
|
||
mkdir -p $VSCODE_USER/prompts
|
||
set PROMPTS_UPDATED 0
|
||
for f in $SOURCE/prompts/*.prompt.md
|
||
set fname (basename $f)
|
||
cp $f $VSCODE_USER/prompts/$fname
|
||
set PROMPTS_UPDATED (math $PROMPTS_UPDATED + 1)
|
||
end
|
||
echo " ✓ $PROMPTS_UPDATED Prompt-Dateien aktualisiert → $VSCODE_USER/prompts/"
|
||
else
|
||
echo " ─ VS Code User-Verzeichnis nicht gefunden, Prompts übersprungen"
|
||
end
|
||
|
||
# ── 4. Repo-lokale Updates (nur wenn in einem Git-Repo) ──────────────────────
|
||
set REPO_ROOT (git rev-parse --show-toplevel 2>/dev/null)
|
||
|
||
if test -z "$REPO_ROOT"
|
||
echo ""
|
||
echo " ─ Kein Git-Repo erkannt – repo-lokale Updates übersprungen"
|
||
echo ""
|
||
echo "=== Done ==="
|
||
exit 0
|
||
end
|
||
|
||
echo ""
|
||
echo " Git-Repo erkannt: $REPO_ROOT"
|
||
|
||
# ── 4a. Git-Hooks aktualisieren ───────────────────────────────────────────────
|
||
set HOOKS_DIR $REPO_ROOT/.git/hooks
|
||
mkdir -p $HOOKS_DIR
|
||
set HOOKS_UPDATED 0
|
||
|
||
for hook in pre-commit post-commit
|
||
if test -f $SOURCE/git-templates/hooks/$hook
|
||
cp $SOURCE/git-templates/hooks/$hook $HOOKS_DIR/$hook
|
||
chmod +x $HOOKS_DIR/$hook
|
||
set HOOKS_UPDATED (math $HOOKS_UPDATED + 1)
|
||
echo " ✓ .git/hooks/$hook aktualisiert"
|
||
end
|
||
end
|
||
|
||
if test $HOOKS_UPDATED -eq 0
|
||
echo " ─ Keine Hook-Templates gefunden"
|
||
end
|
||
|
||
# ── 4b. copilot-instructions.md: nur wenn TODO-Platzhalter vorhanden ─────────
|
||
set COPILOT_INSTRUCTIONS $REPO_ROOT/.github/copilot-instructions.md
|
||
|
||
if test -f $COPILOT_INSTRUCTIONS
|
||
if grep -q "TODO" $COPILOT_INSTRUCTIONS 2>/dev/null
|
||
set BACKUP $COPILOT_INSTRUCTIONS.bak
|
||
cp $COPILOT_INSTRUCTIONS $BACKUP
|
||
cp $SOURCE/git-templates/.github/copilot-instructions.md $COPILOT_INSTRUCTIONS
|
||
echo " ✓ .github/copilot-instructions.md aktualisiert"
|
||
echo " (Backup: .github/copilot-instructions.md.bak)"
|
||
else
|
||
echo " ─ .github/copilot-instructions.md übersprungen (keine TODOs – angepasst)"
|
||
end
|
||
else
|
||
echo " ─ .github/copilot-instructions.md nicht vorhanden, übersprungen"
|
||
end
|
||
|
||
echo ""
|
||
echo "=== Done ==="
|
||
echo "Tipp: 'git copilot-update' jederzeit ausführen um Templates aktuell zu halten."
|