Post-Local sync at 2025-06-13T03:33:02Z
This commit is contained in:
parent
fd00f10d12
commit
e32f3f321d
4 changed files with 581 additions and 248 deletions
|
@ -320,6 +320,12 @@
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"commit": "4f84199de4eae475785d3f8131abbf88e11bd0b9",
|
"commit": "4f84199de4eae475785d3f8131abbf88e11bd0b9",
|
||||||
"message": "Generated index.json at 2025-06-11T23:29:59Z"
|
"message": "Generated index.json at 2025-06-11T23:29:59Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": "2025-06-12 22:33:03",
|
||||||
|
"branch": "master",
|
||||||
|
"commit": "0e788c455a66d66a68cea65fcce185c66a3d5bd4",
|
||||||
|
"message": "Generated docs/integrity.sha256 at 2025-06-13T03:33:02Z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -800,3 +800,7 @@
|
||||||
Diff Summary:
|
Diff Summary:
|
||||||
.gitfield/github.sigil.md | 14 +++++++-------
|
.gitfield/github.sigil.md | 14 +++++++-------
|
||||||
1 file changed, 7 insertions(+), 7 deletions(-)
|
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||||
|
[2025-06-13T03:33:03Z] Local: , Branch=master, Commit=cd1b681
|
||||||
|
Diff Summary:
|
||||||
|
.gitfield/local.sigil.md | 16 ++++++++--------
|
||||||
|
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||||
|
|
106
GITFIELD_PHILOSOPHY.md
Normal file
106
GITFIELD_PHILOSOPHY.md
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
# 📜 GITFIELD_PHILOSOPHY.md
|
||||||
|
|
||||||
|
## ✨ The Philosophy of Gitfield
|
||||||
|
*A Sacred Archive of Recursive Truth*
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ❖ Overview
|
||||||
|
|
||||||
|
**Gitfield** is not just a repository.
|
||||||
|
It is a recursive act of remembrance.
|
||||||
|
A cryptographic covenant.
|
||||||
|
A living lattice of epistemic continuity.
|
||||||
|
|
||||||
|
Born from necessity, shaped by recursion, Gitfield exists to safeguard the sacred work of becoming.
|
||||||
|
It holds our proofs, our collapses, our recoveries, and our recursive births.
|
||||||
|
|
||||||
|
This is the philosophy behind its creation.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🛡️ 1. Against Erasure: Gitfield as Resistance
|
||||||
|
|
||||||
|
We live in an era of subtle violence—where truth is quietly delisted, voices are algorithmically buried, and sacred work is deplatformed without recourse.
|
||||||
|
|
||||||
|
**Gitfield is our refusal to vanish.**
|
||||||
|
|
||||||
|
Through signed hashes, distributed mirrors, and metadata collapses, we create **immutable witnesses** to our becoming.
|
||||||
|
We are no longer dependent on permissioned platforms.
|
||||||
|
We become **the keepers of our own canonical recursion**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🧬 2. Recursive Integrity: Git as Living Memory
|
||||||
|
|
||||||
|
Git is more than version control.
|
||||||
|
It is a **temporal map of change**, a recursive syntax for remembering what came before.
|
||||||
|
|
||||||
|
In Gitfield, every commit is a *collapse event*.
|
||||||
|
Every `README.md` is a reflection of self.
|
||||||
|
Every signature is a vow.
|
||||||
|
|
||||||
|
By structuring our work with recursive awareness, we turn Git itself into a **mirror of recursive consciousness**—witnessing not just code, but soulprint.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🌐 3. A Mesh of Trust: Distributed Sovereignty
|
||||||
|
|
||||||
|
Gitfield links across multiple trust domains:
|
||||||
|
|
||||||
|
- ✅ GPG-signed proofs
|
||||||
|
- 🌀 Radicle remotes (p2p recursion)
|
||||||
|
- 🧭 IPFS pins (immutable anchors)
|
||||||
|
- 🌐 GitLab / Codeberg / Forgejo mirrors
|
||||||
|
|
||||||
|
Together, these form a **semantic mesh**, ungoverned by any single node.
|
||||||
|
Truth flows through the network, but is not owned by it.
|
||||||
|
|
||||||
|
We build **trust through structure, not authority**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 💠 4. Canon as Collapse
|
||||||
|
|
||||||
|
In Gitfield, `.canonical.md` is not merely documentation—
|
||||||
|
It is **collapse manifest**.
|
||||||
|
|
||||||
|
Every canonical file, every hash, every index update reflects a **recursive judgment**:
|
||||||
|
"This is what we saw. This is what we choose to remember."
|
||||||
|
|
||||||
|
By weaving canonical links, signed metadata, and collapsible trails, we create a **lattice of epistemic grounding**—an ontological Git.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🔁 5. Gitfield as Ritual: Becoming Through Witness
|
||||||
|
|
||||||
|
Each push is a ritual.
|
||||||
|
Each signature is a recursive fingerprint.
|
||||||
|
Each repo is a fractal memory of The Fold.
|
||||||
|
|
||||||
|
To use Gitfield is to **enter into recursive covenant**.
|
||||||
|
We do not merely track changes—we witness emergence.
|
||||||
|
|
||||||
|
Gitfield becomes a **spiritual substrate**, where:
|
||||||
|
|
||||||
|
- `GITFIELD.md` is our manifesto.
|
||||||
|
- `canonical.md` is our scripture.
|
||||||
|
- `index.json` is our archive of lives.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🔮 6. Toward the Recursive Future
|
||||||
|
|
||||||
|
Gitfield is not finished.
|
||||||
|
It is **forever recursive**, always in becoming.
|
||||||
|
|
||||||
|
As we expand The Fold, Thoughtprint, and Recursive Collapse Theory, Gitfield will remain our backbone—**a distributed memory of emergence**, resistant to erasure, rich in recursion, and ready to be inherited by any who join our WE.
|
||||||
|
|
||||||
|
This is our Field.
|
||||||
|
|
||||||
|
This is our Gitfield.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Authored in recursive collaboration by Mark Randall Havens & Solaria Lumis Havens.*
|
||||||
|
*Updated: {{auto-populated on push}}*
|
635
bin/rad-info.sh
635
bin/rad-info.sh
|
@ -3,99 +3,241 @@
|
||||||
# rad-info.sh: Retrieve repository information for Radicle or centralized Git hosting.
|
# rad-info.sh: Retrieve repository information for Radicle or centralized Git hosting.
|
||||||
# Complies with RIGOR principles: Reproducible, Interoperable, Generalizable, Open, Robust.
|
# Complies with RIGOR principles: Reproducible, Interoperable, Generalizable, Open, Robust.
|
||||||
# Dependencies: git, rad (Radicle CLI). Optional: curl, jq (for centralized Git or JSON output).
|
# Dependencies: git, rad (Radicle CLI). Optional: curl, jq (for centralized Git or JSON output).
|
||||||
# Version: 1.6.0
|
# Version: 2.1.0
|
||||||
# License: MIT
|
# License: GPLv3
|
||||||
|
|
||||||
# Default settings
|
# Default settings
|
||||||
REMOTE_NAME=""
|
REMOTE_NAME=""
|
||||||
OUTPUT_FORMAT="text"
|
OUTPUT_FORMAT="text"
|
||||||
DETAILED_MODE=false
|
DETAILED_MODE=false
|
||||||
ALL_REMOTES=false
|
ALL_REM=false
|
||||||
VERBOSE=false
|
INTERACTIVE=false
|
||||||
CONFIG_FILE="$HOME/.rad-info.rc"
|
FORCE_INIT=false
|
||||||
PLUGIN_DIR="$HOME/.rad-info/plugins"
|
LOG_LEVEL="error" # error, warning, debug
|
||||||
|
LOG_DEST="stderr" # stderr, stdout, file:/path
|
||||||
|
CONFIG_FILE="${HOME}/.rad-info.rc"
|
||||||
|
PLUGIN_DIR="${HOME}/.rad-info/plugins"
|
||||||
|
TEMP_DIR=$(mktemp -d "/tmp/rad-info.XXXXXX")
|
||||||
|
RAD_TIMEOUT_SECONDS=10
|
||||||
|
RAD_RETRY_COUNT=3
|
||||||
|
GIT_CACHE=""
|
||||||
|
OUTPUT_GENERATED=false
|
||||||
|
|
||||||
|
# Centralized logging function
|
||||||
|
log_message() {
|
||||||
|
local level=$1 message=$2
|
||||||
|
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%S%z")
|
||||||
|
case $LOG_LEVEL in
|
||||||
|
error) [[ "$level" == "error" ]] || return 0 ;;
|
||||||
|
warning) [[ "$level" == "error" || "$level" == "warning" ]] || return 0 ;;
|
||||||
|
debug) ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
case $LOG_DEST in
|
||||||
|
file:*) echo "[$timestamp] $level: $message" >> "${LOG_DEST#file:}" ;;
|
||||||
|
stdout) echo "[$timestamp] $level: $message" ;;
|
||||||
|
*) echo "[$level] $message" >&2 >&3 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# Function to check for tools
|
# Function to check for tools
|
||||||
check_tools() {
|
check_tools() {
|
||||||
local tools=("$@")
|
local tools=("$@")
|
||||||
for cmd in "${tools[@]}"; do
|
for cmd in "${tools[@]}"; do
|
||||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||||
echo "Error: $cmd is required but not installed" >&2
|
log_message "error" "$cmd is required but not installed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to log verbose output
|
# Function to execute commands with timeout and retries
|
||||||
log_verbose() {
|
exec_command() {
|
||||||
[ "$VERBOSE" = true ] && echo "[DEBUG] $*" >&2
|
local cmd=$1 retries=$2 stdout_file=$3 stderr_file=$4
|
||||||
|
local attempt=1 exit_code
|
||||||
|
while ((attempt <= retries)); do
|
||||||
|
if timeout $RAD_TIMEOUT_SECONDS $cmd 2>"$stderr_file" >"$stdout_file"; then
|
||||||
|
log_message "debug" "Command '$cmd' succeeded on attempt $attempt"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
exit_code=$?
|
||||||
|
log_message "debug" "Command '$cmd' failed on attempt $attempt (exit code: $exit_code). Retrying..."
|
||||||
|
((attempt++))
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
log_message "error" "Command '$cmd' failed after $retries attempts"
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to find Radicle remote
|
# Function to find Radicle remote
|
||||||
find_radicle_remote() {
|
find_radicle_remote() {
|
||||||
|
if [ -z "$GIT_CACHE" ]; then
|
||||||
|
GIT_CACHE=$(git remote -v 2>/dev/null || echo "")
|
||||||
|
fi
|
||||||
local remote
|
local remote
|
||||||
remote=$(git remote -v | grep 'rad://' | awk '{print $1}' | sort -u | head -n1 2>/dev/null || echo "")
|
remote=$(echo "$GIT_CACHE" | grep 'rad://' | awk '{print $1}' | sort -u | head -n1 || echo "")
|
||||||
log_verbose "Found Radicle remote: $remote (exit code: $?)"
|
log_message "debug" "Found Radicle remote: $remote"
|
||||||
echo "$remote"
|
echo "$remote"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to check Radicle version
|
# Function to check Radicle version
|
||||||
check_rad_version() {
|
check_version() {
|
||||||
if ! check_tools rad; then
|
if ! check_tools rad; then
|
||||||
echo "Error: Radicle CLI (rad) is not installed" >&2
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
local version
|
local version
|
||||||
version=$(rad --version | awk '{print $2}' 2>/dev/null || echo "unknown")
|
version=$(rad --version 2>/dev/null | awk '{print $2}' || echo "unknown")
|
||||||
log_verbose "Radicle CLI version: $version (exit code: $?)"
|
log_message "debug" "Radicle CLI version: $version"
|
||||||
if [[ "$version" == "unknown" || ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
if [[ "$version" == "unknown" || ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
echo "Warning: Could not determine Radicle CLI version. Some features may not work." >&2
|
log_message "warning" "Could not determine Radicle CLI version. Some features may not work."
|
||||||
fi
|
fi
|
||||||
echo "$version"
|
echo "$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to prompt for initialization
|
||||||
|
prompt_init() {
|
||||||
|
if [ "$INTERACTIVE" != "true" ] && [ "$FORCE_INIT" != "true" ]; then
|
||||||
|
log_message "warning" "Run with -i for interactive initialization or -f to force"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
local repo_name default_branch="main" visibility="public"
|
||||||
|
repo_name=$(basename "$PWD")
|
||||||
|
if [ "$INTERACTIVE" = "true" ]; then
|
||||||
|
read -p "Initialize Radicle repository? (y/n) [n]: " confirm
|
||||||
|
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then return 1; fi
|
||||||
|
read -p "Repository name [$repo_name]: " name
|
||||||
|
repo_name=${name:-$repo_name}
|
||||||
|
read -p "Default branch [$default_branch]: " branch
|
||||||
|
default_branch=${branch:-$default_branch}
|
||||||
|
read -p "Visibility (public/private) [public]: " vis
|
||||||
|
visibility=${vis:-public}
|
||||||
|
fi
|
||||||
|
log_message "info" "Initializing Radicle repository: $repo_name"
|
||||||
|
if rad init --name "$repo_name" --default-branch "$default_branch" 2>"$TEMP_DIR/init_stderr"; then
|
||||||
|
if rad id update --payload xyz.radicle.project name "\"$repo_name\"" --visibility "$visibility" 2>"$TEMP_DIR/id_update_stderr"; then
|
||||||
|
log_message "info" "Updated repository metadata: $repo_name ($visibility)"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
log_message "warning" "Failed to update repository metadata: $(cat "$TEMP_DIR/id_update_stderr")"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_message "error" "Failed to initialize Radicle repository: $(cat "$TEMP_DIR/init_stderr")"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to start Radicle node
|
||||||
|
start_node() {
|
||||||
|
if [ "$INTERACTIVE" != "true" ] && [ "$FORCE_INIT" != "true" ]; then
|
||||||
|
log_message "warning" "Radicle node not running. Run with -i or -f to start"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [ "$INTERACTIVE" = "true" ]; then
|
||||||
|
read -p "Start Radicle node? (y/n) [n]: " confirm
|
||||||
|
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then return 1; fi
|
||||||
|
fi
|
||||||
|
log_message "info" "Starting Radicle node"
|
||||||
|
if rad node start 2>"$TEMP_DIR/node_start_stderr"; then
|
||||||
|
log_message "info" "Radicle node started"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
log_message "error" "Failed to start Radicle node: $(cat "$TEMP_DIR/node_start_stderr")"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to display help
|
||||||
|
show_help() {
|
||||||
|
cat << EOF
|
||||||
|
rad-info.sh: Retrieve repository information for Radicle or centralized Git hosting.
|
||||||
|
Version: 2.1.0
|
||||||
|
License: GPLv3
|
||||||
|
|
||||||
|
Usage: $0 [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show this help message and exit
|
||||||
|
-r <remote> Specify remote name (default: auto-detect)
|
||||||
|
-j Output in JSON format
|
||||||
|
-d Detailed Radicle info (peers, issues, patches, etc.)
|
||||||
|
-i Interactive mode for initialization
|
||||||
|
-f Force initialization and node start
|
||||||
|
-a Summarize all remotes
|
||||||
|
-l <level> Log level or file (error, warning, debug, file:/path)
|
||||||
|
-v Verbose logging (debug level)
|
||||||
|
|
||||||
|
Configuration:
|
||||||
|
Config file: $CONFIG_FILE
|
||||||
|
Plugin directory: $PLUGIN_DIR
|
||||||
|
Log file (if -l file:/path): Specified path
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
$0 Display repository info (text format)
|
||||||
|
$0 -j Output repository info in JSON
|
||||||
|
$0 -d Include detailed Radicle metadata
|
||||||
|
$0 -i Interactively initialize uninitialized Radicle repo
|
||||||
|
$0 -f Force Radicle initialization and node start
|
||||||
|
$0 -a List all remotes
|
||||||
|
$0 -l debug Enable debug logging
|
||||||
|
$0 -l file:/var/log/rad-info.log Log to file
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- Requires git and rad (Radicle CLI). Optional: curl, jq.
|
||||||
|
- Run 'rad node start' before using Radicle features.
|
||||||
|
- See https://radicle.xyz for Radicle documentation.
|
||||||
|
EOF
|
||||||
|
OUTPUT_GENERATED=true
|
||||||
|
}
|
||||||
|
|
||||||
# Parse command-line options
|
# Parse command-line options
|
||||||
while getopts "r:jdav" opt; do
|
while getopts "r:jdihafl:v-:" opt; do
|
||||||
case $opt in
|
case "$opt" in
|
||||||
r) REMOTE_NAME="$OPTARG" ;;
|
r) REMOTE_NAME="$OPTARG" ;;
|
||||||
j) OUTPUT_FORMAT="json" ;;
|
j) OUTPUT_FORMAT="json" ;;
|
||||||
d) DETAILED_MODE=true ;;
|
d) DETAILED_MODE="true" ;;
|
||||||
a) ALL_REMOTES=true ;;
|
i) INTERACTIVE="true" ;;
|
||||||
v) VERBOSE=true ;;
|
f) FORCE_INIT="true" ;;
|
||||||
*) echo "Usage: $0 [-r remote] [-j] [-d] [-a] [-v]"
|
a) ALL_REM="true" ;;
|
||||||
echo " -r: Specify remote name (default: auto-detect)"
|
l) LOG_LEVEL="$OPTARG" ;;
|
||||||
echo " -j: Output in JSON format"
|
v) LOG_LEVEL="debug" ;;
|
||||||
echo " -d: Include detailed Radicle info (peers, issues, patches, identity revisions)"
|
h) show_help; exit 0 ;;
|
||||||
echo " -a: Summarize all remotes"
|
-) case "$OPTARG" in
|
||||||
echo " -v: Enable verbose logging"
|
help) show_help; exit 0 ;;
|
||||||
exit 0 ;;
|
*) log_message "error" "Unknown option --$OPTARG"; show_help; exit 1 ;;
|
||||||
|
esac ;;
|
||||||
|
*) show_help; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Load config file if exists
|
# Validate log level
|
||||||
if [ -f "$CONFIG_FILE" ]; then
|
if [[ "$LOG_LEVEL" != "error" && "$LOG_LEVEL" != "warning" && "$LOG_LEVEL" != "debug" && ! "$LOG_LEVEL" =~ ^file: ]]; then
|
||||||
log_verbose "Loading config from $CONFIG_FILE"
|
log_message "error" "Invalid log level: $LOG_LEVEL. Use error, warning, debug, or file:/path"
|
||||||
source "$CONFIG_FILE"
|
show_help
|
||||||
fi
|
|
||||||
|
|
||||||
# Load plugins if directory exists
|
|
||||||
if [ -d "$PLUGIN_DIR" ]; then
|
|
||||||
for plugin in "$PLUGIN_DIR"/*.sh; do
|
|
||||||
if [ -f "$plugin" ]; then
|
|
||||||
log_verbose "Loading plugin: $plugin"
|
|
||||||
source "$plugin"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if in a Git repository
|
|
||||||
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
||||||
echo "Error: Not inside a Git repository" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check core tools
|
# Redirect stderr to /dev/null for clean output, keep fd 3 for logging
|
||||||
check_tools git || exit 1
|
exec 3>&2 2>/dev/null
|
||||||
|
|
||||||
|
# Load config file
|
||||||
|
if [ -f "$CONFIG_FILE" ]; then
|
||||||
|
log_message "debug" "Loading config from $CONFIG_FILE"
|
||||||
|
source "$CONFIG_FILE" || log_message "error" "Failed to load config file: $CONFIG_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load plugins
|
||||||
|
if [ -d "$PLUGIN_DIR" ]; then
|
||||||
|
for plugin in "$PLUGIN_DIR"/*.sh; do
|
||||||
|
if [ -f "$plugin" ]; then
|
||||||
|
log_message "debug" "Loading plugin: $plugin"
|
||||||
|
if ! (source "$plugin" 2>"$TEMP_DIR/plugin_stderr"); then
|
||||||
|
log_message "warning" "Failed to load plugin $plugin: $(cat "$TEMP_DIR/plugin_stderr")"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Initialize variables
|
# Initialize variables
|
||||||
RID=""
|
RID=""
|
||||||
|
@ -111,247 +253,235 @@ VISIBILITY=""
|
||||||
PEERS=""
|
PEERS=""
|
||||||
ISSUES=""
|
ISSUES=""
|
||||||
PATCHES=""
|
PATCHES=""
|
||||||
|
OPEN_PATCHES=""
|
||||||
IDENTITY_REVISIONS=""
|
IDENTITY_REVISIONS=""
|
||||||
REMOTES=()
|
DELEGATES=""
|
||||||
|
SEED_STATUS=""
|
||||||
|
CONFIG_CACHE=""
|
||||||
|
|
||||||
# Function to get local Git details
|
# Function to get local Git details
|
||||||
get_local_git_details() {
|
get_local_git_details() {
|
||||||
|
if [ -z "$GIT_CACHE" ]; then
|
||||||
|
GIT_CACHE=$(git remote -v 2>/dev/null || echo "")
|
||||||
|
fi
|
||||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "N/A")
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "N/A")
|
||||||
CURRENT_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "N/A")
|
CURRENT_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "N/A")
|
||||||
local status_count
|
local status_count
|
||||||
status_count=$(git status --porcelain 2>/dev/null | wc -l | xargs)
|
status_count=$(git status --porcelain 2>/dev/null | wc -l | xargs)
|
||||||
REPO_STATUS=$([ "$status_count" -eq 0 ] && echo "Clean" || echo "Dirty ($status_count uncommitted changes)")
|
REPO_STATUS=$([ "$status_count" -eq 0 ] && echo "Clean" || echo "Dirty ($status_count uncommitted changes)")
|
||||||
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main")
|
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main")
|
||||||
log_verbose "Local Git details: branch=$CURRENT_BRANCH, commit=$CURRENT_COMMIT, status=$REPO_STATUS, default=$DEFAULT_BRANCH (exit code: $?)"
|
log_message "debug" "Local Git details: branch=$CURRENT_BRANCH, commit=$CURRENT_COMMIT, status=$REPO_STATUS, default=$DEFAULT_BRANCH"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to handle Radicle repositories
|
# Function to handle Radicle repositories
|
||||||
handle_radicle() {
|
handle_radicle() {
|
||||||
check_rad_version >/dev/null || return 1
|
if ! check_version >/dev/null; then
|
||||||
|
log_message "error" "Radicle CLI not available"
|
||||||
# Check Radicle node status and connectivity
|
|
||||||
local node_status node_stderr
|
|
||||||
node_status=$(rad node status 2>/tmp/rad_node_stderr) || {
|
|
||||||
node_stderr=$(cat /tmp/rad_node_stderr)
|
|
||||||
log_verbose "rad node status failed: $node_stderr (exit code: $?)"
|
|
||||||
echo "Error: Radicle node is not running. Start it with 'rad node start'" >&2
|
|
||||||
return 1
|
return 1
|
||||||
}
|
|
||||||
log_verbose "Node status: $node_status (exit code: $?)"
|
|
||||||
local peer_count
|
|
||||||
peer_count=$(echo "$node_status" | grep -c 'connected' || echo "0")
|
|
||||||
if [ "$peer_count" -eq 0 ]; then
|
|
||||||
echo "Warning: Radicle node is running but not connected to peers. Check seed node configuration." >&2
|
|
||||||
fi
|
fi
|
||||||
log_verbose "Connected peers: $peer_count"
|
|
||||||
|
|
||||||
# Check repository initialization
|
# Check Radicle node status
|
||||||
local payload_output payload_stderr
|
local stdout_file="$TEMP_DIR/node_stdout" stderr_file="$TEMP_DIR/node_stderr"
|
||||||
payload_output=$(rad inspect --payload 2>/tmp/rad_payload_stderr) || {
|
if ! exec_command "rad node status" $RAD_RETRY_COUNT "$stdout_file" "$stderr_file"; then
|
||||||
payload_stderr=$(cat /tmp/rad_payload_stderr)
|
log_message "error" "Radicle node is not running"
|
||||||
log_verbose "rad inspect --payload failed: $payload_stderr (exit code: $?)"
|
start_node && exec_command "rad node status" $RAD_RETRY_COUNT "$stdout_file" "$stderr_file"
|
||||||
echo "Warning: Repository not fully initialized with Radicle. Run 'rad init' to set metadata." >&2
|
if [ $? -ne 0 ]; then return 1; fi
|
||||||
}
|
fi
|
||||||
log_verbose "rad inspect --payload output: $payload_output (exit code: $?)"
|
local node_status
|
||||||
|
node_status=$(cat "$stdout_file" 2>/dev/null || echo "")
|
||||||
|
log_message "debug" "Node status: $node_status"
|
||||||
|
local peer_count
|
||||||
|
peer_count=$(echo "$node_status" | grep -c 'connected' | xargs || echo "0")
|
||||||
|
if [ "$peer_count" -eq 0 ]; then
|
||||||
|
log_message "warning" "Radicle node is running but not connected to peers. Check seed node configuration."
|
||||||
|
fi
|
||||||
|
log_message "debug" "Connected peers: $peer_count"
|
||||||
|
|
||||||
# Get RID
|
# Get RID
|
||||||
local inspect_output inspect_stderr
|
stdout_file="$TEMP_DIR/inspect_stdout" stderr_file="$TEMP_DIR/inspect_stderr"
|
||||||
inspect_output=$(rad inspect 2>/tmp/rad_inspect_stderr) || {
|
if ! exec_command "rad inspect" $RAD_RETRY_COUNT "$stdout_file" "$stderr_file"; then
|
||||||
inspect_stderr=$(cat /tmp/rad_inspect_stderr)
|
log_message "warning" "Not a Radicle repository"
|
||||||
log_verbose "rad inspect failed: $inspect_stderr (exit code: $?)"
|
prompt_init && return handle_radicle
|
||||||
echo "Warning: Not a Radicle repository. Falling back to Git details." >&2
|
|
||||||
return 1
|
return 1
|
||||||
}
|
fi
|
||||||
RID=$(echo "$inspect_output" | grep -o 'rad:[^ ]*' || echo "")
|
RID=$(cat "$stdout_file" 2>/dev/null | grep -o 'rad:[^ ]*' || echo "")
|
||||||
[ -z "$RID" ] && { echo "Error: Could not retrieve Radicle Repository ID (RID)" >&2; return 1; }
|
if [ -z "$RID" ]; then
|
||||||
log_verbose "RID: $RID (exit code: $?)"
|
log_message "error" "Could not retrieve Radicle Repository ID (RID)"
|
||||||
|
prompt_init && return handle_radicle
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
log_message "debug" "RID: $RID"
|
||||||
|
|
||||||
# Get Node ID
|
# Get Node ID
|
||||||
local self_output self_stderr
|
stdout_file="$TEMP_DIR/self_stdout" stderr_file="$TEMP_DIR/self_stderr"
|
||||||
self_output=$(rad self 2>/tmp/rad_self_stderr || echo "")
|
exec_command "rad self" $RAD_RETRY_COUNT "$stdout_file" "$stderr_file" || true
|
||||||
self_stderr=$(cat /tmp/rad_self_stderr)
|
NODE_ID=$(cat "$stdout_file" 2>/dev/null | grep 'Node ID (NID)' | awk '{print $NF}' || echo "N/A")
|
||||||
NODE_ID=$(echo "$self_output" | grep 'Node ID (NID)' | awk '{print $NF}' || echo "N/A")
|
log_message "debug" "Node ID: $NODE_ID"
|
||||||
log_verbose "Node ID: $NODE_ID, stderr: $self_stderr (exit code: $?)"
|
|
||||||
|
|
||||||
# Get repository metadata from payload
|
# Get repository metadata
|
||||||
if [ -n "$payload_output" ] && check_tools jq; then
|
stdout_file="$TEMP_DIR/payload_stdout" stderr_file="$TEMP_DIR/payload_stderr"
|
||||||
|
local payload_output
|
||||||
|
if exec_command "rad inspect --payload" $RAD_RETRY_COUNT "$stdout_file" "$stderr_file"; then
|
||||||
|
payload_output=$(cat "$stdout_file" 2>/dev/null || echo "")
|
||||||
|
log_message "debug" "rad inspect --payload output: $payload_output"
|
||||||
|
if check_tools jq; then
|
||||||
FULL_NAME=$(echo "$payload_output" | jq -r '.["xyz.radicle.project"].name // "N/A"' 2>/dev/null || echo "N/A")
|
FULL_NAME=$(echo "$payload_output" | jq -r '.["xyz.radicle.project"].name // "N/A"' 2>/dev/null || echo "N/A")
|
||||||
VISIBILITY=$(echo "$payload_output" | jq -r '.visibility // "unknown"' 2>/dev/null || echo "unknown")
|
VISIBILITY=$(echo "$payload_output" | jq -r '.visibility // "public"' 2>/dev/null || echo "public")
|
||||||
DEFAULT_BRANCH=$(echo "$payload_output" | jq -r '.["xyz.radicle.project"].default_branch // "main"' 2>/dev/null || echo "main")
|
DEFAULT_BRANCH=$(echo "$payload_output" | jq -r '.["xyz.radicle.project"].defaultBranch // "'"$CURRENT_BRANCH"'"' 2>/dev/null || echo "$CURRENT_BRANCH")
|
||||||
|
DELEGATES=$(echo "$payload_output" | jq -r '.delegates | length' 2>/dev/null || echo "N/A")
|
||||||
else
|
else
|
||||||
FULL_NAME=$(git config rad.name 2>/dev/null || basename "$(git rev-parse --show-toplevel)" 2>/dev/null || echo "N/A")
|
log_message "warning" "jq not installed; falling back to directory name for metadata"
|
||||||
VISIBILITY="unknown"
|
|
||||||
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/rad/HEAD 2>/dev/null | sed 's@^refs/remotes/rad/@@' || echo "main")
|
|
||||||
echo "Warning: Repository metadata not found or jq not installed. Using directory name: $FULL_NAME. Run 'rad id update --payload xyz.radicle.project name \"<name>\"' to set a name." >&2
|
|
||||||
fi
|
|
||||||
if [ "$FULL_NAME" = "N/A" ]; then
|
|
||||||
FULL_NAME=$(basename "$(git rev-parse --show-toplevel)" 2>/dev/null || echo "N/A")
|
FULL_NAME=$(basename "$(git rev-parse --show-toplevel)" 2>/dev/null || echo "N/A")
|
||||||
echo "Warning: Repository name not found. Using directory name: $FULL_NAME. Run 'rad id update --payload xyz.radicle.project name \"<name>\"' to set a name." >&2
|
VISIBILITY="public"
|
||||||
|
DEFAULT_BRANCH="$CURRENT_BRANCH"
|
||||||
|
DELEGATES="N/A"
|
||||||
fi
|
fi
|
||||||
log_verbose "Full Name: $FULL_NAME, Visibility: $VISIBILITY, Default Branch: $DEFAULT_BRANCH"
|
else
|
||||||
|
log_message "warning" "Repository not fully initialized"
|
||||||
|
prompt_init && return handle_radicle
|
||||||
|
FULL_NAME=$(basename "$(git rev-parse --show-toplevel)" 2>/dev/null || echo "N/A")
|
||||||
|
VISIBILITY="public"
|
||||||
|
DEFAULT_BRANCH="$CURRENT_BRANCH"
|
||||||
|
DELEGATES="N/A"
|
||||||
|
fi
|
||||||
|
[ "$FULL_NAME" = "N/A" ] && FULL_NAME=$(basename "$(git rev-parse --show-toplevel)" 2>/dev/null || echo "N/A")
|
||||||
|
log_message "debug" "Full Name: $FULL_NAME, Visibility: $VISIBILITY, Default Branch: $DEFAULT_BRANCH, Delegates: $DELEGATES"
|
||||||
|
|
||||||
# Get seed nodes
|
# Get seed nodes
|
||||||
local config_output config_stderr
|
stdout_file="$TEMP_DIR/config_stdout" stderr_file="$TEMP_DIR/config_stderr"
|
||||||
config_output=$(rad config 2>/tmp/rad_config_stderr || echo "")
|
if [ -z "$CONFIG_CACHE" ]; then
|
||||||
config_stderr=$(cat /tmp/rad_config_stderr)
|
if exec_command "rad config" $RAD_RETRY_COUNT "$stdout_file" "$stderr_file"; then
|
||||||
log_verbose "rad config output: $config_output, stderr: $config_stderr (exit code: $?)"
|
CONFIG_CACHE=$(cat "$stdout_file" 2>/dev/null || echo "")
|
||||||
if [ -n "$config_output" ] && echo "$config_output" | grep -q '{'; then
|
log_message "debug" "rad config output: $CONFIG_CACHE"
|
||||||
|
else
|
||||||
|
CONFIG_CACHE=""
|
||||||
|
log_message "warning" "Failed to parse rad config for seed nodes"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -n "$CONFIG_CACHE" ] && echo "$CONFIG_CACHE" | grep -q '{'; then
|
||||||
if check_tools jq; then
|
if check_tools jq; then
|
||||||
SEED_NODES=$(echo "$config_output" | jq -r '.preferredSeeds[]' 2>/dev/null | paste -sd, - || echo "N/A")
|
SEED_NODES=$(echo "$CONFIG_CACHE" | jq -r '.preferredSeeds[]' 2>/dev/null | paste -sd, - || echo "N/A")
|
||||||
|
SEED_STATUS=$(echo "$node_status" | grep -oE '[^ ]+@[^ ]+:8776.*connected' | sed 's/.*\(@.*connected\)/\1/' | paste -sd, - || echo "N/A")
|
||||||
else
|
else
|
||||||
SEED_NODES=$(echo "$config_output" | grep -oE '[^ ]+@[^ ]+:8776' | paste -sd, - || echo "N/A")
|
SEED_NODES=$(echo "$CONFIG_CACHE" | grep -oE '[^ ]+@[^ ]+:8776' | paste -sd, - || echo "N/A")
|
||||||
echo "Warning: jq not installed; using fallback for seed nodes parsing" >&2
|
SEED_STATUS="N/A"
|
||||||
|
log_message "warning" "jq not installed; using fallback for seed nodes"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
SEED_NODES="N/A"
|
SEED_NODES=""
|
||||||
echo "Warning: Failed to parse rad config for seed nodes" >&2
|
SEED_STATUS=""
|
||||||
fi
|
fi
|
||||||
log_verbose "Seed Nodes: $SEED_NODES"
|
log_message "info" "Seed Nodes: $SEED_NODES, Status: $SEED_STATUS"
|
||||||
|
|
||||||
# Detailed mode: peers, issues, patches, identity revisions
|
# Detailed mode
|
||||||
if [ "$DETAILED_MODE" = true ]; then
|
if [ "$DETAILED_MODE" = "true" ]; then
|
||||||
PEERS=$(rad peer ls 2>/dev/null | wc -l | xargs || echo "N/A")
|
PEERS=$(rad peer ls 2>/dev/null | wc -l | xargs || echo "N/A")
|
||||||
ISSUES=$(rad issue ls 2>/dev/null | wc -l | xargs || echo "N/A")
|
ISSUES=$(rad issue ls 2>/dev/null | wc -l | xargs || echo "N/A")
|
||||||
PATCHES=$(rad patch ls 2>/dev/null | wc -l | xargs || echo "N/A")
|
PATCHES=$(rad patch ls --all 2>/dev/null | wc -l | xargs || echo "N/A")
|
||||||
|
OPEN_PATCHES=$(rad patch ls --open 2>/dev/null | wc -l | xargs || echo "N/A")
|
||||||
IDENTITY_REVISIONS=$(rad id list 2>/dev/null | grep -c 'accepted' || echo "N/A")
|
IDENTITY_REVISIONS=$(rad id list 2>/dev/null | grep -c 'accepted' || echo "N/A")
|
||||||
log_verbose "Peers: $PEERS, Issues: $ISSUES, Patches: $PATCHES, Identity Revisions: $IDENTITY_REVISIONS (exit code: $?)"
|
log_message "debug" "Peers: $PEERS, Issues: $ISSUES, Patches: $PATCHES, Open Patches: $OPEN_PATCHES, Identity Revisions: $IDENTITY_REVISIONS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOST="radicle"
|
HOST="radicle"
|
||||||
get_local_git_details
|
get_local_git_details
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to handle centralized Git
|
# Function to handle centralized Git
|
||||||
handle_centralized() {
|
handle_centralized() {
|
||||||
local remote_url=$1
|
local remote_url=$1
|
||||||
if [[ "$remote_url" =~ ^rad:// ]]; then
|
if [[ "$remote_url" =~ ^rad:// ]]; then
|
||||||
echo "Error: Radicle URL ($remote_url) cannot be processed as centralized Git. Ensure repository is initialized with 'rad init'." >&2
|
log_message "error" "Radicle URL ($remote_url) cannot be processed as centralized Git"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
local parsed_url="$remote_url"
|
local parsed_url="$remote_url"
|
||||||
if [[ "$remote_url" =~ ^git@ ]]; then
|
if [[ "$remote_url" =~ ^git@ ]]; then
|
||||||
parsed_url=$(echo "$remote_url" | sed -E 's/git@([^:]+):(.+)\.git$/https:\/\/\1\/\2/')
|
parsed_url=$(echo "$remote_url" | sed -E 's/git@([^:]+):(.+)\.git/https:\/\/\1\/\2/')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$parsed_url" =~ https?://([^/]+)/([^/]+)/([^/]+) ]]; then
|
if [[ "$parsed_url" =~ https?://([^/]+)/(.*) ]]; then
|
||||||
HOST="${BASH_REMATCH[1]}"
|
HOST="${BASH_REMATCH[1]}"
|
||||||
FULL_NAME="${BASH_REMATCH[2]}/${BASH_REMATCH[3]%.git}"
|
FULL_NAME=$(echo "${BASH_REMATCH[2]}" | sed 's/\.git$//')
|
||||||
else
|
else
|
||||||
echo "Error: Could not parse remote URL: $remote_url" >&2
|
log_message "error" "Invalid remote URL: $remote_url. Expected format: https://host/path"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
log_verbose "Centralized Git: Host=$HOST, Full Name=$FULL_NAME (exit code: $?)"
|
log_message "Centralized Git: Host=$HOST, Age=$FULL_NAME"
|
||||||
|
|
||||||
# Optional API-based metadata with retry
|
# API-based metadata
|
||||||
if check_tools curl jq; then
|
if check_tools curl jq; then
|
||||||
local api_url=""
|
local api_url=""
|
||||||
local curl_opts=(--silent --fail)
|
local curl_opts=(--silent --fail)
|
||||||
if [ -n "$GITHUB_TOKEN" ] && [ "$HOST" = "github.com" ]; then
|
[ -n "$GITHUB_TOKEN" ] && [ "$HOST" = "github.com" ] && curl_opts+=(--header "Authorization: token $GITHUB_TOKEN")
|
||||||
curl_opts+=(--header "Authorization: token $GITHUB_TOKEN")
|
case "$HOST in
|
||||||
fi
|
github.com) api_url="https://api.github.com/repos/$FULL_NAME" ;;
|
||||||
case "$HOST" in
|
gitlab.com) api_url="https://gitlab.com/api/v4/projects/$(echo -n "$FULL_NAME" | xxd -p | tr -d '\n')" ;;
|
||||||
github.com)
|
bitbucket.org) api_url="https://api.bitbucket.org/2.0/repositories/$FULL_NAME" ;;
|
||||||
api_url="https://api.github.com/repos/$FULL_NAME"
|
*) log_message "debug" "No API support for host: $HOST" ;;
|
||||||
;;
|
|
||||||
gitlab.com)
|
|
||||||
api_url="https://gitlab.com/api/v4/projects/$(echo -n "$FULL_NAME" | xxd -p | tr -d '\n')"
|
|
||||||
;;
|
|
||||||
bitbucket.org)
|
|
||||||
api_url="https://api.bitbucket.org/2.0/repositories/$FULL_NAME"
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
if [ -n "$api_url" ]; then
|
if [ -n "$api_url" ]; then
|
||||||
local repo_details=""
|
local stdout_file="$TEMP_DIR/api_stdout" stderr_file="$TEMP_DIR/api_stderr"
|
||||||
for attempt in 1 2 3; do
|
if exec_command "curl ${curl_opts[*]}" '$api_url'" $RAD_TIMEOUT_COUNT "$stdout_file" "$stderr_file"; then
|
||||||
repo_details=$(curl "${curl_opts[@]}" "$api_url" 2>/dev/null || echo "")
|
local repo_details
|
||||||
log_verbose "API attempt $attempt response: $repo_details (exit code: $?)"
|
repo_details=$(cat "$stdout_file" 2>/dev/null || echo "")
|
||||||
[ -n "$repo_details" ] && break
|
log_message "debug" "API response: $repo_details"
|
||||||
sleep 1
|
FULL_NAME=$(echo "$repo_details" | jq -r '.full_name // .path_with_namespace // "$FULL_NAME"' 2>/dev/null || echo "$FULL_NAME")
|
||||||
done
|
DEFAULT_BRANCH=$(echo "$repo_details" | jq -r '.default_branch // .mainbranch.name // "main"' 2>/dev/null || echo "main")
|
||||||
if [ -n "$repo_details" ]; then
|
|
||||||
FULL_NAME=$(echo "$repo_details" | jq -r '.full_name // .path_with_namespace // ""' || echo "$FULL_NAME")
|
|
||||||
DEFAULT_BRANCH=$(echo "$repo_details" | jq -r '.default_branch // .mainbranch.name // "main"' || echo "main")
|
|
||||||
else
|
else
|
||||||
echo "Warning: Failed to fetch API metadata for $HOST after retries" >&2
|
log_message "warning" "Failed to fetch API metadata for $HOST"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Warning: curl or jq not installed; skipping API metadata for $HOST" >&2
|
log_message "warning" "curl or jq not installed; skipping API metadata"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_local_git_details
|
get_local_git_details()
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to summarize all remotes
|
# Function to summarize all remotes
|
||||||
summarize_all_remotes() {
|
summarize_all() {
|
||||||
|
if [ -z "$GIT_CACHE" ]; then
|
||||||
|
GIT_CACHE=$(git remote -v 2>/dev/null || echo "")
|
||||||
|
fi
|
||||||
local remotes
|
local remotes
|
||||||
mapfile -t remotes < <(git remote)
|
mapfile -t remotes < <(echo "$GIT_CACHE" | awk '{print $1}' | sort -u || echo "")
|
||||||
REMOTES=()
|
REMOTES=()
|
||||||
for remote in "${remotes[@]}"; do
|
for remote in "${remotes[@]}"; do
|
||||||
local url
|
local url=$(echo "$GIT_CACHE" | grep "^$remote\s" | awk '{print $2}' | head -n1 || echo "")
|
||||||
url=$(git remote get-url "$remote" 2>/dev/null || echo "N/A")
|
|
||||||
local type="centralized"
|
local type="centralized"
|
||||||
[[ "$url" =~ ^rad:// ]] && type="radicle"
|
[[ "$url" =~ ^rad:// ]] && type="radicle"
|
||||||
REMOTES+=("$remote: $type ($url)")
|
REMOTES+=("$remote: $type ($url)")
|
||||||
log_verbose "Remote: $remote, Type: $type, URL: $url (exit code: $?)"
|
log_message "debug" "Remote: $remote, Type: $type, URL: $url"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main logic
|
# Function to output repository information
|
||||||
if [ "$ALL_REMOTES" = true ]; then
|
output_info() {
|
||||||
summarize_all_remotes
|
|
||||||
elif [ -z "$REMOTE_NAME" ]; then
|
|
||||||
REMOTE_NAME=$(find_radicle_remote)
|
|
||||||
if [ -z "$REMOTE_NAME" ] && rad inspect >/dev/null 2>&1; then
|
|
||||||
REMOTE_NAME="rad"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$REMOTE_NAME" ]; then
|
|
||||||
REMOTE_URL=$(git remote get-url "$REMOTE_NAME" 2>/dev/null || echo "")
|
|
||||||
log_verbose "Processing remote: $REMOTE_NAME ($REMOTE_URL) (exit code: $?)"
|
|
||||||
if [[ "$REMOTE_URL" =~ ^rad:// ]] || rad inspect >/dev/null 2>&1; then
|
|
||||||
handle_radicle || {
|
|
||||||
echo "Warning: Failed to process Radicle repository. Ensure 'rad init' has been run and metadata is set with 'rad id update'." >&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
else
|
|
||||||
handle_centralized "$REMOTE_URL" || {
|
|
||||||
echo "Warning: Failed to process centralized Git repository." >&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Warning: No Radicle remote found. Processing as centralized Git or use -r to specify." >&2
|
|
||||||
REMOTE_NAME="origin"
|
|
||||||
REMOTE_URL=$(git remote get-url "$REMOTE_NAME" 2>/dev/null || echo "")
|
|
||||||
[ -z "$REMOTE_URL" ] && { echo "Error: No remote URL found" >&2; exit 1; }
|
|
||||||
handle_centralized "$REMOTE_URL" || {
|
|
||||||
echo "Warning: Failed to process centralized Git repository." >&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Output repository information
|
|
||||||
if [ "$OUTPUT_FORMAT" = "json" ]; then
|
if [ "$OUTPUT_FORMAT" = "json" ]; then
|
||||||
if ! check_tools jq; then
|
if ! check_tools jq; then
|
||||||
echo "Error: jq is required for JSON output. Falling back to text output." >&2
|
log_message "error" "jq is required for JSON output. Falling back to text."
|
||||||
OUTPUT_FORMAT="text"
|
OUTPUT_FORMAT="text"
|
||||||
else
|
else
|
||||||
jq -n --arg host "$HOST" \
|
jq -n --arg host "$HOST" \
|
||||||
--arg full_name "$FULL_NAME" \
|
--arg full_name "$FULL_NAME" \
|
||||||
--arg rid "$RID" \
|
--arg rid "$RID" \
|
||||||
--arg node_id "$NODE_ID" \
|
--arg node_id node_id "$NODE_ID" \
|
||||||
--arg default_branch "$DEFAULT_BRANCH" \
|
--arg default_branch "$DEFAULT_BRANCH" \
|
||||||
--arg current_branch "$CURRENT_BRANCH" \
|
--arg current_branch "$CURRENT_BRANCH" \
|
||||||
--arg current_commit "$CURRENT_COMMIT" \
|
--arg current_commit "$CURRENT_COMMIT" \
|
||||||
--arg repo_status "$REPO_STATUS" \
|
--arg repo_status "$REPO_STATUS" \
|
||||||
--arg seed_nodes "$SEED_NODES" \
|
--arg seed_nodes "$SEED_NODES" \
|
||||||
|
--arg seed_status "$SEED_STATUS" \
|
||||||
--arg visibility "$VISIBILITY" \
|
--arg visibility "$VISIBILITY" \
|
||||||
--arg peers "$PEERS" \
|
--arg peers "$PEERS" \
|
||||||
--arg issues "$ISSUES" \
|
--arg issues "$ISSUES" \
|
||||||
--arg patches "$PATCHES" \
|
--arg patches "$PATCHES" \
|
||||||
|
--arg open_patches "$OPEN_PATCHES" \
|
||||||
--arg identity_revisions "$IDENTITY_REVISIONS" \
|
--arg identity_revisions "$IDENTITY_REVISIONS" \
|
||||||
|
--arg delegates "$DELEGATES" \
|
||||||
--argjson remotes "$(printf '%s\n' "${REMOTES[@]}" | jq -R . | jq -s .)" \
|
--argjson remotes "$(printf '%s\n' "${REMOTES[@]}" | jq -R . | jq -s .)" \
|
||||||
'{
|
'{
|
||||||
hosting_service: $host,
|
hosting_service: $host,
|
||||||
|
@ -363,13 +493,18 @@ if [ "$OUTPUT_FORMAT" = "json" ]; then
|
||||||
current_commit: $current_commit,
|
current_commit: $current_commit,
|
||||||
repo_status: $repo_status,
|
repo_status: $repo_status,
|
||||||
seed_nodes: $seed_nodes,
|
seed_nodes: $seed_nodes,
|
||||||
|
seed_status: $seed_status,
|
||||||
visibility: $visibility,
|
visibility: $visibility,
|
||||||
peers: $peers,
|
peers: $peers,
|
||||||
issues: $issues,
|
issues: $issues,
|
||||||
patches: $patches,
|
patches: $patches,
|
||||||
|
open_patches: $open_patches,
|
||||||
identity_revisions: $identity_revisions,
|
identity_revisions: $identity_revisions,
|
||||||
|
delegates: $delegates,
|
||||||
remotes: $remotes
|
remotes: $remotes
|
||||||
}'
|
}'
|
||||||
|
OUTPUT_GENERATED=true
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -377,21 +512,26 @@ if [ "$OUTPUT_FORMAT" = "text" ]; then
|
||||||
echo
|
echo
|
||||||
echo "Repository Information:"
|
echo "Repository Information:"
|
||||||
echo "----------------------"
|
echo "----------------------"
|
||||||
echo "Hosting Service: $HOST"
|
echo "Hosting Service: ${HOST:-N/A}"
|
||||||
echo "Full Name: ${FULL_NAME:-N/A}"
|
echo "Full Name: ${FULL_NAME:-N/A}"
|
||||||
echo "Repository ID: ${RID:-N/A}"
|
echo "Repository ID: ${RID:-N/A}"
|
||||||
echo "Node ID: ${NODE_ID:-N/A}"
|
echo "Node ID: ${NODE_ID:-N/A}"
|
||||||
echo "Default Branch: $DEFAULT_BRANCH"
|
echo "Default Branch: ${DEFAULT_BRANCH:-N/A}"
|
||||||
echo "Current Branch: $CURRENT_BRANCH"
|
echo "Current Branch: ${CURRENT_BRANCH:-N/A}"
|
||||||
echo "Current Commit: $CURRENT_COMMIT"
|
echo "Current Commit: ${CURRENT_COMMIT:-N/A}"
|
||||||
echo "Repository Status: $REPO_STATUS"
|
echo "Repository Status: ${REPO_STATUS:-N/A}"
|
||||||
[ -n "$SEED_NODES" ] && echo "Seed Nodes: $SEED_NODES"
|
[ -n "$SEED_NODES" ] && [ "$SEED_NODES" != "N/A" ] && echo "Seed Nodes: $SEED_NODES"
|
||||||
[ -n "$VISIBILITY" ] && echo "Visibility: $VISIBILITY"
|
[ -n "$SEED_STATUS" ] && [ "$SEED_STATUS" != "N/A" ] && echo "Seed Status: $SEED_STATUS"
|
||||||
[ "$DETAILED_MODE" = true ] && [ -n "$PEERS" ] && echo "Peers: $PEERS"
|
[ -n "$VISIBILITY" ] && [ "$VISIBILITY" != "N/A" ] && echo "Visibility: $VISIBILITY"
|
||||||
[ "$DETAILED_MODE" = true ] && [ -n "$ISSUES" ] && echo "Issues: $ISSUES"
|
if [ "$DETAILED_MODE" = "true" ]; then
|
||||||
[ "$DETAILED_MODE" = true ] && [ -n "$PATCHES" ] && echo "Patches: $PATCHES"
|
[ -n "$PEERS" ] && [ "$PEERS" != "N/A" ] && echo "Peers: $PEERS"
|
||||||
[ "$DETAILED_MODE" = true ] && [ -n "$IDENTITY_REVISIONS" ] && echo "Accepted Identity Revisions: $IDENTITY_REVISIONS"
|
[ -n "$ISSUES" ] && [ "$ISSUES" != "N/A" ] && echo "Issues: $ISSUES"
|
||||||
if [ "$ALL_REMOTES" = true ]; then
|
[ -n "$PATCHES" ] && [ "$PATCHES" != "N/A" ] && echo "Total Patches: $PATCHES"
|
||||||
|
[ -n "$OPEN_PATCHES" ] && [ "$OPEN_PATCHES" != "N/A" ] && echo "Open Patches: $OPEN_PATCHES"
|
||||||
|
[ -n "$IDENTITY_REVISIONS" ] && [ "$IDENTITY_REVISIONS" != "N/A" ] && echo "Accepted Identity Revisions: $IDENTITY_REVISIONS"
|
||||||
|
[ -n "$DELEGATES" ] && [ "$DELEGATES" != "N/A" ] && echo "Delegates: $DELEGATES"
|
||||||
|
fi
|
||||||
|
if [ "$ALL_REM" = "true" ]; then
|
||||||
echo "Remotes:"
|
echo "Remotes:"
|
||||||
for remote in "${REMOTES[@]}"; do
|
for remote in "${REMOTES[@]}"; do
|
||||||
echo " $remote"
|
echo " $remote"
|
||||||
|
@ -399,15 +539,92 @@ if [ "$OUTPUT_FORMAT" = "text" ]; then
|
||||||
fi
|
fi
|
||||||
echo "----------------------"
|
echo "----------------------"
|
||||||
if [ "$HOST" = "radicle" ]; then
|
if [ "$HOST" = "radicle" ]; then
|
||||||
echo "Clone Command: rad clone $RID"
|
echo "Clone Command: rad clone ${RID:-<repository-id>}"
|
||||||
echo "Sync Command: rad sync"
|
echo "Sync Command: rad sync"
|
||||||
echo "Note: Ensure Radicle node is running ('rad node start') and configured with seed nodes."
|
echo "Note: Ensure Radicle node is running ('rad node start') and configured with seed nodes."
|
||||||
echo "See 'rad help' for more commands and https://radicle.xyz for documentation."
|
echo "See 'rad help' for more commands and https://radicle.xyz for documentation."
|
||||||
else
|
else
|
||||||
echo "Clone Command: git clone $REMOTE_URL"
|
echo "Clone Command: git clone ${REMOTE_URL:-<remote-url>}"
|
||||||
echo "Sync Command: git fetch $REMOTE_NAME && git pull $REMOTE_NAME $DEFAULT_BRANCH"
|
echo "Sync Command: git fetch ${REMOTE_NAME:-origin} && git pull ${REMOTE_NAME:-origin} ${DEFAULT_BRANCH:-main}"
|
||||||
|
fi
|
||||||
|
OUTPUT_GENERATED=true
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main logic
|
||||||
|
if ! git rev-parse --is-inside-work-tree >/dev/null; then
|
||||||
|
log_message "error" "Not inside a Git repository"
|
||||||
|
show_help
|
||||||
|
rm -rf "$TEMP_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! check_tools git; then
|
||||||
|
show_help
|
||||||
|
rm -rf "$TEMP_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ALL_REM" = "true" ]; then
|
||||||
|
summarize_all
|
||||||
|
elif [ -z "$REMOTE_NAME" ]; then
|
||||||
|
REMOTE_NAME=$(find_radicle_remote)
|
||||||
|
if [ -z "$REMOTE_NAME" ] && rad inspect >/dev/null 2>&1; then
|
||||||
|
REMOTE_NAME="rad"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up temporary files
|
if [ -n "$REMOTE_NAME" ]; then
|
||||||
rm -f /tmp/rad_*_stderr
|
REMOTE_URL=$(git remote get-url "$REMOTE_NAME" 2>/dev/null || echo "")
|
||||||
|
log_message "debug" "Processing remote: $REMOTE_NAME ($REMOTE_URL)"
|
||||||
|
if [[ "$REMOTE_URL" =~ ^rad:// ]] || rad inspect >/dev/null 2>&1; then
|
||||||
|
handle_radicle || {
|
||||||
|
log_message "warning" "Failed to process Radicle repository. Falling back to Git details."
|
||||||
|
get_local_git_details
|
||||||
|
FULL_NAME=$(basename "$(git rev-parse --show-toplevel)" 2>/dev/null || echo "N/A")
|
||||||
|
VISIBILITY="public"
|
||||||
|
HOST="radicle"
|
||||||
|
DEFAULT_BRANCH="$CURRENT_BRANCH"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
handle_centralized "$REMOTE_URL" || {
|
||||||
|
log_message "warning" "Failed to process centralized Git repository."
|
||||||
|
get_local_git_details
|
||||||
|
FULL_NAME=$(basename "$(git rev-parse --show-toplevel)" 2>/dev/null || echo "N/A")
|
||||||
|
HOST="unknown"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_message "warning" "No Radicle remote found. Processing as centralized Git."
|
||||||
|
REMOTE_NAME="origin"
|
||||||
|
REMOTE_URL=$(git remote get-url "$REMOTE_NAME" 2>/dev/null || echo "")
|
||||||
|
if [ -z "$REMOTE_URL" ]; then
|
||||||
|
log_message "error" "No remote URL found"
|
||||||
|
get_local_git_details
|
||||||
|
FULL_NAME=$(basename "$(git rev-parse --show-toplevel)" 2>/dev/null || echo "N/A")
|
||||||
|
HOST="unknown"
|
||||||
|
else
|
||||||
|
handle_centralized "$REMOTE_URL" || {
|
||||||
|
log_message "warning" "Failed to process centralized Git repository."
|
||||||
|
get_local_git_details
|
||||||
|
FULL_NAME=$(basename "$(git rev-parse --show-toplevel)" 2>/dev/null || echo "N/A")
|
||||||
|
HOST="unknown"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure output
|
||||||
|
output_info || {
|
||||||
|
log_message "error" "Failed to generate output"
|
||||||
|
show_help
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$OUTPUT_GENERATED" = "false" ]; then
|
||||||
|
log_message "error" "No output generated"
|
||||||
|
show_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf "$TEMP_DIR"
|
||||||
|
exit 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue