Commit 67810806e8c8

Vincent Demeester <vincent@sbr.pm>
2026-07-28 16:52:05
fix(kyushu): rewrite clone-repos with upstream remotes
Idempotent: checks existing repos, fixes origin URLs, adds missing upstream remotes. Covers all osp, tektoncd, and tektoncd-catalog repos with their upstream counterparts.
1 parent 0cd5b54
Changed files (1)
imperative
imperative/kyushu/clone-repos.sh
@@ -1,52 +1,106 @@
 #!/usr/bin/env bash
-# Clone work repositories on kyushu
+# Clone work repositories on kyushu (idempotent)
 # Run after SSH keys (TPM + FIDO2) are set up and gh auth is done
 set -euo pipefail
 
-echo "Cloning work repositories into ~/src/..."
+clone_or_check() {
+  local path="$1" origin="$2"
+  shift 2
+  # Remaining args are pairs: remote_name remote_url
+  if [[ -d "$path/.git" ]]; then
+    echo "✓ $path (exists)"
+    # Ensure origin is correct
+    local current
+    current=$(git -C "$path" remote get-url origin 2>/dev/null || true)
+    if [[ "$current" != "$origin" ]]; then
+      echo "  ⚠ origin mismatch: $current → $origin"
+      git -C "$path" remote set-url origin "$origin"
+    fi
+  else
+    mkdir -p "$(dirname "$path")"
+    echo "⊕ $path ← $origin"
+    git clone "$origin" "$path"
+  fi
+  # Add/update extra remotes
+  while [[ $# -ge 2 ]]; do
+    local name="$1" url="$2"
+    shift 2
+    local current
+    current=$(git -C "$path" remote get-url "$name" 2>/dev/null || true)
+    if [[ -z "$current" ]]; then
+      echo "  + remote $name → $url"
+      git -C "$path" remote add "$name" "$url"
+    elif [[ "$current" != "$url" ]]; then
+      echo "  ⚠ $name mismatch: $current → $url"
+      git -C "$path" remote set-url "$name" "$url"
+    fi
+  done
+}
 
-# Home infra (carthage)
-mkdir -p ~/src
-git clone vincent@carthage.vpn:/home/vincent/git/public/home.git ~/src/home || echo "home: already exists"
-git clone vincent@carthage.vpn:git/public/www.git ~/src/www || echo "www: already exists"
+echo "Setting up ~/src/ repositories..."
+echo
 
-# Praetorian
-mkdir -p ~/src/vdemeester
-git clone git@github.com:vdemeester/praetorian.git ~/src/vdemeester/praetorian || echo "praetorian: already exists"
+# --- Home infra (carthage) ---
+clone_or_check ~/src/home \
+  "vincent@carthage.vpn:/home/vincent/git/public/home.git"
+clone_or_check ~/src/www \
+  "vincent@carthage.vpn:git/public/www.git"
 
-# OpenShift Pipelines (osp)
-mkdir -p ~/src/osp
-for repo in \
-  ai-approver ambient-workflows architecture catalog-cd cfp-radar \
-  console-plugin cookbook coverage-dashboard docs ecosystem-images \
-  hack knowledge-base manual-approval-gate multi-cluster \
-  multicluster-proxy-aae must-gather osp-component-dashboard \
-  plumbing skills tekton-assist tekton-kueue tkn-autogenerate; do
-  git clone "git@github.com:vdemeester/openshift-pipelines-${repo}.git" ~/src/osp/"$repo" || echo "osp/$repo: already exists"
+# --- Praetorian ---
+clone_or_check ~/src/vdemeester/praetorian \
+  "git@github.com:vdemeester/praetorian.git"
+
+# --- OpenShift Pipelines (osp) ---
+osp_repos=(
+  ai-approver ambient-workflows architecture catalog-cd cfp-radar
+  console-plugin cookbook coverage-dashboard docs ecosystem-images
+  hack knowledge-base manual-approval-gate multi-cluster
+  multicluster-proxy-aae must-gather osp-component-dashboard
+  plumbing skills tekton-assist tekton-kueue tkn-autogenerate
+)
+for repo in "${osp_repos[@]}"; do
+  clone_or_check ~/src/osp/"$repo" \
+    "git@github.com:vdemeester/openshift-pipelines-${repo}.git" \
+    upstream "https://github.com/openshift-pipelines/${repo}.git"
 done
-git clone https://github.com/vdemeester/openshift-pipelines-opc.git ~/src/osp/opc || echo "osp/opc: already exists"
+clone_or_check ~/src/osp/opc \
+  "https://github.com/vdemeester/openshift-pipelines-opc.git" \
+  upstream "https://github.com/openshift-pipelines/opc.git"
 
-# Tekton upstream
-mkdir -p ~/src/tektoncd
-for repo in \
-  actions catalog catlin chains cli community dashboard \
-  mcp-server operator pipeline plumbing pruner results triggers website; do
-  git clone "git@github.com:vdemeester/tektoncd-${repo}.git" ~/src/tektoncd/"$repo" || echo "tektoncd/$repo: already exists"
+# --- Tekton upstream ---
+tektoncd_repos=(
+  actions catalog catlin chains cli community dashboard
+  mcp-server operator pipeline plumbing pruner results triggers website
+)
+for repo in "${tektoncd_repos[@]}"; do
+  clone_or_check ~/src/tektoncd/"$repo" \
+    "git@github.com:vdemeester/tektoncd-${repo}.git" \
+    upstream "https://github.com/tektoncd/${repo}.git"
 done
-git clone git@github.com:vdemeester/pipelines-as-code.git ~/src/tektoncd/pipelines-as-code || echo "tektoncd/pipelines-as-code: already exists"
-git clone https://github.com/tektoncd/infra.git ~/src/tektoncd/infra || echo "tektoncd/infra: already exists"
-git clone https://github.com/vdemeester/tektoncd-dotgithub.git ~/src/tektoncd/.github || echo "tektoncd/.github: already exists"
-git clone https://github.com/vdemeester/tekton-docusaurus-poc.git ~/src/tektoncd/docusaurus-poc || echo "tektoncd/docusaurus-poc: already exists"
-git clone https://github.com/vdemeester/upstream-highlights.git ~/src/tektoncd/upstream-highlights || echo "tektoncd/upstream-highlights: already exists"
+clone_or_check ~/src/tektoncd/pipelines-as-code \
+  "git@github.com:vdemeester/pipelines-as-code.git" \
+  upstream "https://github.com/tektoncd/pipelines-as-code.git"
+clone_or_check ~/src/tektoncd/infra \
+  "https://github.com/tektoncd/infra.git"
+clone_or_check ~/src/tektoncd/.github \
+  "https://github.com/vdemeester/tektoncd-dotgithub.git" \
+  upstream "https://github.com/tektoncd/.github.git"
+clone_or_check ~/src/tektoncd/docusaurus-poc \
+  "https://github.com/vdemeester/tekton-docusaurus-poc.git"
+clone_or_check ~/src/tektoncd/upstream-highlights \
+  "https://github.com/vdemeester/upstream-highlights.git"
 
-# Tekton catalog repos
-mkdir -p ~/src/tektoncd-catalog
-for repo in git-clone golang kaniko; do
-  git clone "git@github.com:vdemeester/tektoncd-catalog-${repo}.git" ~/src/tektoncd-catalog/"$repo" || echo "tektoncd-catalog/$repo: already exists"
+# --- Tekton catalog repos ---
+tektoncd_catalog_repos=(git-clone golang kaniko)
+for repo in "${tektoncd_catalog_repos[@]}"; do
+  clone_or_check ~/src/tektoncd-catalog/"$repo" \
+    "git@github.com:vdemeester/tektoncd-catalog-${repo}.git" \
+    upstream "https://github.com/tektoncd-catalog/${repo}.git"
 done
 
-# Other
-mkdir -p ~/src/carlos
-git clone https://github.com/carlos-salinas/pipelines-lab ~/src/carlos/pipelines-lab || echo "carlos/pipelines-lab: already exists"
+# --- Other ---
+clone_or_check ~/src/carlos/pipelines-lab \
+  "https://github.com/carlos-salinas/pipelines-lab"
 
-echo "Done! $(find ~/src -name '.git' -type d | wc -l) repos cloned."
+echo
+echo "Done! $(find ~/src -name '.git' -type d | wc -l) repos in ~/src/"