mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 23:36:11 +00:00
chore: add phase 0 spike scripts and results
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
5f54fb88f8
6 files changed
+99
No files matched your search
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Start a throwaway Forgejo (dev only) on localhost:3300 with an admin user.
|
||||
set -euo pipefail
|
||||
podman rm -f gitsync-forgejo >/dev/null 2>&1 || true
|
||||
podman run -d --name gitsync-forgejo -p 3300:3000 \
|
||||
-e FORGEJO__security__INSTALL_LOCK=true \
|
||||
-e FORGEJO__server__ROOT_URL=http://localhost:3300/ \
|
||||
-e FORGEJO__server__DISABLE_SSH=true \
|
||||
-e FORGEJO__database__DB_TYPE=sqlite3 \
|
||||
-e FORGEJO__mirror__ENABLED=true -e FORGEJO__migrations__ALLOW_LOCALNETWORKS=true -e FORGEJO__migrations__ALLOWED_DOMAINS=localhost \
|
||||
codeberg.org/forgejo/forgejo:11 >/dev/null
|
||||
for i in $(seq 60); do curl -fs localhost:3300/api/healthz >/dev/null && break; sleep 1; done
|
||||
podman exec --user git gitsync-forgejo forgejo admin user create --admin \
|
||||
--username spike --password spike-pass-123 --email spike@example.invalid --must-change-password=false
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# Phase 0 spike against a local throwaway Forgejo (run spikes/forgejo-up.sh first).
|
||||
set -euo pipefail
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
API=http://localhost:3300/api/v1; AUTH=spike:spike-pass-123
|
||||
w=$(mktemp -d); cd "$w"
|
||||
curl -fs -u $AUTH -H 'Content-Type: application/json' -X POST $API/user/repos \
|
||||
-d '{"name":"demo","private":true}' >/dev/null
|
||||
curl -fs -u $AUTH -H 'Content-Type: application/json' -X POST $API/user/repos \
|
||||
-d '{"name":"demo-mirror","private":true}' >/dev/null
|
||||
URL=http://spike:spike-pass-123@localhost:3300/spike/demo.git
|
||||
git init -q -b main m1 && cd m1
|
||||
git config user.email a@b.c; git config user.name t
|
||||
echo hi > a.txt; git add a.txt; git commit -qm init
|
||||
git remote add origin $URL; git push -q origin main
|
||||
echo "wip" > untracked.txt; echo "edit" >> a.txt; echo secret > ignored.env; echo "*.env" > .gitignore
|
||||
c=$("$here/snapshot.sh" . desktop); echo "snapshot: $c"
|
||||
echo "--- push refs/sync (force)"
|
||||
git push -f origin "refs/sync/desktop/main:refs/sync/desktop/main" 2>&1 | tail -3
|
||||
echo "--- ls-remote"; git ls-remote origin
|
||||
echo "--- API branches"; curl -fs -u $AUTH $API/repos/spike/demo/branches | python3 -c 'import sys,json;print([b["name"] for b in json.load(sys.stdin)])'
|
||||
echo "--- API git refs"; curl -fs -u $AUTH "$API/repos/spike/demo/git/refs" | python3 -c 'import sys,json;print([r["ref"] for r in json.load(sys.stdin)])'
|
||||
echo "--- 2nd machine fetch + restore"
|
||||
cd "$w"; git clone -q $URL m2 && cd m2
|
||||
git fetch -q origin "+refs/sync/*:refs/sync/*"; git for-each-ref refs/sync
|
||||
git show --stat refs/sync/desktop/main | head -12
|
||||
git ls-tree -r --name-only refs/sync/desktop/main
|
||||
echo "--- push mirror to demo-mirror"
|
||||
curl -s -u $AUTH -H 'Content-Type: application/json' -X POST $API/repos/spike/demo/push_mirrors \
|
||||
-d '{"remote_address":"http://localhost:3000/spike/demo-mirror.git","remote_username":"spike","remote_password":"spike-pass-123","interval":"8h","sync_on_commit":true}' | head -c 300; echo
|
||||
sleep 1; curl -s -u $AUTH -X POST $API/repos/spike/demo/mirror-sync -o /dev/null -w "mirror-sync http=%{http_code}\n"
|
||||
cd "$w/m1"; echo more >> a.txt; git commit -qam second; git push -q origin main; sleep 8
|
||||
echo "--- mirror refs"; git ls-remote http://spike:spike-pass-123@localhost:3300/spike/demo-mirror.git
|
||||
echo "workdir: $w"
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prototype: snapshot a worktree (tracked+staged+untracked, minus ignored)
|
||||
# into refs/sync/<machine>/<branch> without touching branch, index or history.
|
||||
# Usage: snapshot.sh <worktree> <machine>
|
||||
set -euo pipefail
|
||||
wt=$1; machine=$2
|
||||
cd "$wt"
|
||||
gitdir=$(git rev-parse --absolute-git-dir)
|
||||
branch=$(git symbolic-ref --short HEAD)
|
||||
ref="refs/sync/$machine/$branch"
|
||||
tmp=$(mktemp); trap 'rm -f "$tmp"' EXIT
|
||||
cp "$gitdir/index" "$tmp" 2>/dev/null || true
|
||||
export GIT_INDEX_FILE=$tmp
|
||||
git add -A
|
||||
tree=$(git write-tree)
|
||||
prev=$(git rev-parse -q --verify "$ref" || true)
|
||||
if [ -n "$prev" ] && [ "$(git rev-parse "$prev^{tree}")" = "$tree" ]; then echo "unchanged $prev"; exit 0; fi
|
||||
parents=(-p HEAD); [ -n "$prev" ] && parents+=(-p "$prev")
|
||||
commit=$(git commit-tree "$tree" "${parents[@]}" -m "gitsync snapshot $machine $(date -u +%FT%TZ)")
|
||||
git update-ref "$ref" "$commit"
|
||||
echo "$commit"
|
||||
Reference in new issue
Block a user