From 8347b45e7fefc0eb36386187a4e7a53361e002ff Mon Sep 17 00:00:00 2001 From: Mark Randall Havens Date: Sat, 31 May 2025 08:03:49 -0500 Subject: [PATCH] Post-GitHub sync at 2025-05-31 08:03:42 --- .gitfield/.radicle-push-state | 2 +- .gitfield/pushed.log | 4 + gitfield-sync | 184 ++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 .gitfield/pushed.log create mode 100755 gitfield-sync diff --git a/.gitfield/.radicle-push-state b/.gitfield/.radicle-push-state index 6d0c0b9..8abf567 100644 --- a/.gitfield/.radicle-push-state +++ b/.gitfield/.radicle-push-state @@ -1 +1 @@ -1cc98103a35a4b189a2e5199db850e25af3dc9db +e7c667c73af952a483b4f0fc97d6673d89519e4d diff --git a/.gitfield/pushed.log b/.gitfield/pushed.log new file mode 100644 index 0000000..e9824be --- /dev/null +++ b/.gitfield/pushed.log @@ -0,0 +1,4 @@ +# Push Log for git-sigil +# Generated by gitfield-sync + +[2025-05-31 08:03:49] GitHub: https://github.com/mrhavens/git-sigil diff --git a/gitfield-sync b/gitfield-sync new file mode 100755 index 0000000..f5f2b20 --- /dev/null +++ b/gitfield-sync @@ -0,0 +1,184 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +# ╭─────────────────────────────────────╮ +# │ CONFIGURATION │ +# ╰─────────────────────────────────────╯ +REPO_NAME=$(basename "$(pwd)") +REPO_PATH=$(git rev-parse --show-toplevel) +GITFIELD_DIR="$REPO_PATH/.gitfield" +LOG_FILE="$GITFIELD_DIR/pushed.log" +GITFIELD_MD="$REPO_PATH/GITFIELD.md" +TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S') +SCRIPT_VERSION="1.0" + +# URLs for each platform (derived from existing scripts) +GITHUB_URL="https://github.com/mrhavens/$REPO_NAME" +GITLAB_URL="https://gitlab.com/mrhavens/$REPO_NAME" +BITBUCKET_URL="https://bitbucket.org/thefoldwithin/$REPO_NAME" +RADICLE_PROJECT_ID="z45QC21eWL1F43VSbnV9AZbCZrHQJ" # From gitfield-radicle output +RADICLE_URL="https://app.radicle.xyz/nodes/ash.radicle.garden/rad:$RADICLE_PROJECT_ID" + +# ╭─────────────────────────────────────╮ +# │ LOGGING UTILS │ +# ╰─────────────────────────────────────╮ +info() { echo -e "\e[1;34m[INFO]\e[0m $*"; } +warn() { echo -e "\e[1;33m[WARN]\e[0m $*"; } +error() { echo -e "\e[1;31m[ERROR]\e[0m $*" >&2; exit 1; } + +# ╭─────────────────────────────────────╮ +# │ INITIAL SETUP │ +# ╰─────────────────────────────────────╮ +# Ensure .gitfield directory exists +mkdir -p "$GITFIELD_DIR" + +# Initialize log file if it doesn't exist +if [ ! -f "$LOG_FILE" ]; then + echo "# Push Log for $REPO_NAME" > "$LOG_FILE" + echo "# Generated by gitfield-sync" >> "$LOG_FILE" + echo "" >> "$LOG_FILE" +fi + +# ╭─────────────────────────────────────╮ +# │ GENERATE GITFIELD.MD │ +# ╰─────────────────────────────────────╮ +generate_gitfield_md() { + info "Generating $GITFIELD_MD..." + cat > "$GITFIELD_MD" <> "$LOG_FILE" + info "Logged push to $LOG_FILE: [$timestamp] $platform: $url" +} + +# ╭─────────────────────────────────────╮ +# │ EXECUTE PUSH SCRIPT │ +# ╰─────────────────────────────────────╮ +execute_push() { + local script=$1 + local platform=$2 + local url=$3 + info "Running $script for $platform..." + if [ -x "$script" ]; then + ./"$script" || warn "Execution of $script failed, continuing..." + # Log the URL after successful push + log_url "$platform" "$url" + # Add and commit any new files generated by the script + git add . || warn "Nothing to add after $script" + git commit -m "Post-$platform sync at $TIMESTAMP" || warn "No changes to commit after $script" + else + error "Script $script is not executable or does not exist" + fi +} + +# ╭─────────────────────────────────────╮ +# │ RECURSIVE PUSH LOOP │ +# ╰─────────────────────────────────────╮ +run_push_cycle() { + local cycle_number=$1 + info "Starting push cycle $cycle_number..." + + # Push to each platform in order + execute_push "gitfield-github" "GitHub" "$GITHUB_URL" + execute_push "gitfield-gitlab" "GitLab" "$GITLAB_URL" + execute_push "gitfield-bitbucket" "Bitbucket" "$BITBUCKET_URL" + execute_push "gitfield-radicle" "Radicle" "$RADICLE_URL" +} + +# ╭─────────────────────────────────────╮ +# │ MAIN EXECUTION │ +# ╰─────────────────────────────────────╮ +info "Starting gitfield-sync for $REPO_NAME..." + +# Ensure the repository is initialized +if [ ! -d .git ]; then + git init + git add . + git commit -m "Initial commit" || warn "Nothing to commit" +fi + +# Run the first push cycle +run_push_cycle 1 + +# Generate GITFIELD.md after the first cycle +generate_gitfield_md + +# Run the second push cycle to include GITFIELD.md +run_push_cycle 2 + +# Run the third push cycle for final metadata sync +run_push_cycle 3 + +info "✅ gitfield-sync completed successfully." +info "🔗 View logs: $LOG_FILE" +info "🔗 View multi-repo manifest: $GITFIELD_MD"