gitfield-resolve.sh
1 #!/bin/bash 2 3 echo "π οΈ [GITFIELD] Beginning auto-resolution ritual..." 4 5 # Ensure weβre in a Git repo 6 if ! git rev-parse --git-dir > /dev/null 2>&1; then 7 echo "β Not a Git repository. Aborting." 8 exit 1 9 fi 10 11 # Ensure at least one commit exists 12 if ! git log > /dev/null 2>&1; then 13 echo "π No commits found. Creating seed commit..." 14 git add . 15 git commit --allow-empty -m "π± Seed commit for Radicle and GitField rituals" 16 fi 17 18 # GPG sign commit if enabled 19 GPG_KEY=$(git config user.signingkey) 20 if [ -n "$GPG_KEY" ]; then 21 echo "π GPG commit signing enabled with key: $GPG_KEY" 22 git commit -S --allow-empty -m "π Ritual signed commit [auto]" 23 fi 24 25 # Stage and commit any local changes 26 if ! git diff --quiet || ! git diff --cached --quiet; then 27 git add . 28 git commit -m "π Auto-resolve commit from gitfield-resolve.sh" 29 echo "β Local changes committed." 30 else 31 echo "β No changes to commit." 32 fi 33 34 # Loop through remotes 35 remotes=$(git remote) 36 for remote in $remotes; do 37 echo "π Checking $remote for divergence..." 38 git fetch $remote 39 if git merge-base --is-ancestor $remote/master master; then 40 echo "β $remote is already in sync." 41 else 42 echo "β οΈ Divergence with $remote. Attempting merge..." 43 git pull --no-rebase $remote master --strategy-option=theirs --allow-unrelated-histories 44 git push $remote master || echo "β οΈ Final push failed to $remote" 45 fi 46 done 47 48 # ==== RADICLE SECTION ==== 49 50 echo "π± [RADICLE] Verifying Radicle status..." 51 52 # Check if Radicle is initialized 53 if ! rad inspect > /dev/null 2>&1; then 54 echo "πΏ No Radicle project detected. Attempting init..." 55 RAD_INIT_OUTPUT=$(rad init --name git-sigil --description "GitField Ritual Repo") 56 echo "$RAD_INIT_OUTPUT" 57 fi 58 59 # Push to Radicle and announce 60 echo "π‘ Announcing to Radicle network..." 61 rad push --announce 62 63 # Get project ID 64 PROJECT_ID=$(rad inspect | grep "Project ID" | awk '{print $NF}') 65 if [ -n "$PROJECT_ID" ]; then 66 echo "π Logging Radicle project ID to .gitfield/radicle.sigil.md" 67 mkdir -p .gitfield 68 echo "# Radicle Sigil" > .gitfield/radicle.sigil.md 69 echo "**Project ID:** \`$PROJECT_ID\`" >> .gitfield/radicle.sigil.md 70 fi 71 72 echo "β GitField resolution ritual complete."