#!/bin/bash echo "πŸ› οΈ [GITFIELD] Beginning auto-resolution ritual..." # Ensure we’re in a Git repo if ! git rev-parse --git-dir > /dev/null 2>&1; then echo "❌ Not a Git repository. Aborting." exit 1 fi # Ensure at least one commit exists if ! git log > /dev/null 2>&1; then echo "πŸŒ€ No commits found. Creating seed commit..." git add . git commit --allow-empty -m "🌱 Seed commit for Radicle and GitField rituals" fi # GPG sign commit if enabled GPG_KEY=$(git config user.signingkey) if [ -n "$GPG_KEY" ]; then echo "πŸ” GPG commit signing enabled with key: $GPG_KEY" git commit -S --allow-empty -m "πŸ” Ritual signed commit [auto]" fi # Stage and commit any local changes if ! git diff --quiet || ! git diff --cached --quiet; then git add . git commit -m "πŸ”„ Auto-resolve commit from gitfield-resolve.sh" echo "βœ… Local changes committed." else echo "βœ… No changes to commit." fi # Loop through remotes remotes=$(git remote) for remote in $remotes; do echo "πŸ” Checking $remote for divergence..." git fetch $remote if git merge-base --is-ancestor $remote/master master; then echo "βœ… $remote is already in sync." else echo "⚠️ Divergence with $remote. Attempting merge..." git pull --no-rebase $remote master --strategy-option=theirs --allow-unrelated-histories git push $remote master || echo "⚠️ Final push failed to $remote" fi done # ==== RADICLE SECTION ==== echo "🌱 [RADICLE] Verifying Radicle status..." # Check if Radicle is initialized if ! rad inspect > /dev/null 2>&1; then echo "🌿 No Radicle project detected. Attempting init..." RAD_INIT_OUTPUT=$(rad init --name git-sigil --description "GitField Ritual Repo") echo "$RAD_INIT_OUTPUT" fi # Push to Radicle and announce echo "πŸ“‘ Announcing to Radicle network..." rad push --announce # Get project ID PROJECT_ID=$(rad inspect | grep "Project ID" | awk '{print $NF}') if [ -n "$PROJECT_ID" ]; then echo "πŸ“œ Logging Radicle project ID to .gitfield/radicle.sigil.md" mkdir -p .gitfield echo "# Radicle Sigil" > .gitfield/radicle.sigil.md echo "**Project ID:** \`$PROJECT_ID\`" >> .gitfield/radicle.sigil.md fi echo "βœ… GitField resolution ritual complete."