This commit is contained in:
Mark Randall Havens 2025-05-30 08:04:33 -05:00
parent 7a86f69629
commit 7f0867986f
3 changed files with 26 additions and 27 deletions

1
.radicle-push-state Normal file
View file

@ -0,0 +1 @@
7a86f69629e6970f3901b93cf50c234f5e04c1c2

0
.test5 Normal file
View file

View file

@ -15,17 +15,17 @@ RAD_KEYS="$RAD_HOME/keys.json"
RAD_BACKUP=".radicle-backup/keys.json" RAD_BACKUP=".radicle-backup/keys.json"
RAD_PATH_LINE='export PATH="$HOME/.radicle/bin:$PATH"' RAD_PATH_LINE='export PATH="$HOME/.radicle/bin:$PATH"'
PROFILE_FILE="$HOME/.bashrc" PROFILE_FILE="$HOME/.bashrc"
RAD_PUSH_FILE=".radicle-push-done" PUSH_STATE_FILE=".radicle-push-state"
# ╭───────────────────────────────╮ # ╭───────────────────────────────╮
# │ Logging # │ Logging Utils
# ╰───────────────────────────────╯ # ╰───────────────────────────────╯
info() { echo -e "\e[1;34m[INFO]\e[0m $*"; } info() { echo -e "\e[1;34m[INFO]\e[0m $*"; }
warn() { echo -e "\e[1;33m[WARN]\e[0m $*"; } warn() { echo -e "\e[1;33m[WARN]\e[0m $*"; }
error() { echo -e "\e[1;31m[ERROR]\e[0m $*" >&2; exit 1; } error() { echo -e "\e[1;31m[ERROR]\e[0m $*" >&2; exit 1; }
# ╭───────────────────────────────╮ # ╭───────────────────────────────╮
# │ Git + Tools Precheck │ # │ Git + Tools Precheck
# ╰───────────────────────────────╯ # ╰───────────────────────────────╯
info "Checking Git..." info "Checking Git..."
command -v git >/dev/null || { command -v git >/dev/null || {
@ -44,7 +44,7 @@ EMAIL=$(git config --global user.email || true)
info "Git identity: $(git config --global user.name) <$(git config --global user.email)>" info "Git identity: $(git config --global user.name) <$(git config --global user.email)>"
# ╭───────────────────────────────╮ # ╭───────────────────────────────╮
# │ Install Radicle CLI │ # │ Radicle CLI Setup
# ╰───────────────────────────────╯ # ╰───────────────────────────────╯
if [ ! -x "$RAD_BIN" ]; then if [ ! -x "$RAD_BIN" ]; then
info "Installing Radicle CLI..." info "Installing Radicle CLI..."
@ -52,19 +52,14 @@ if [ ! -x "$RAD_BIN" ]; then
curl -sSf https://radicle.xyz/install | sh || error "Radicle install failed" curl -sSf https://radicle.xyz/install | sh || error "Radicle install failed"
fi fi
# ─ PATH Setup (Temporary + Persistent) export PATH="$HOME/.radicle/bin:$PATH"
if ! command -v rad &>/dev/null; then
export PATH="$HOME/.radicle/bin:$PATH"
info "→ Temporarily patched PATH for this session"
fi
if ! grep -Fxq "$RAD_PATH_LINE" "$PROFILE_FILE"; then if ! grep -Fxq "$RAD_PATH_LINE" "$PROFILE_FILE"; then
echo "$RAD_PATH_LINE" >> "$PROFILE_FILE" echo "$RAD_PATH_LINE" >> "$PROFILE_FILE"
info "→ Added PATH to $PROFILE_FILE" info "→ Added PATH to $PROFILE_FILE"
warn "→ Run 'source $PROFILE_FILE' to make 'rad' persistent" warn "→ Run 'source $PROFILE_FILE' to make Radicle CLI persistent"
fi fi
command -v rad >/dev/null || error "Radicle CLI still unavailable. Try restarting your terminal." command -v rad >/dev/null || error "Radicle CLI still unavailable. Try restarting terminal."
info "Radicle CLI ready: $(rad --version)" info "Radicle CLI ready: $(rad --version)"
@ -86,16 +81,16 @@ else
fi fi
# ╭───────────────────────────────╮ # ╭───────────────────────────────╮
# │ Start Rad Node # │ Start Rad Node │
# ╰───────────────────────────────╯ # ╰───────────────────────────────╯
pgrep -f "rad node start" &>/dev/null || { pgrep -f "rad node start" >/dev/null || {
info "Starting Radicle node..." info "Starting Radicle node..."
nohup rad node start > /dev/null 2>&1 & nohup rad node start > /dev/null 2>&1 &
sleep 3 sleep 3
} }
# ╭───────────────────────────────╮ # ╭───────────────────────────────╮
# │ Initialize Git Repo # │ Git Repo Initialization
# ╰───────────────────────────────╯ # ╰───────────────────────────────╯
if [ ! -d .git ]; then if [ ! -d .git ]; then
git init git init
@ -106,7 +101,7 @@ else
fi fi
# ╭───────────────────────────────╮ # ╭───────────────────────────────╮
# │ Register Radicle Project # │ Radicle Project Registration
# ╰───────────────────────────────╯ # ╰───────────────────────────────╯
if ! rad projects | grep -q "$PROJECT_NAME"; then if ! rad projects | grep -q "$PROJECT_NAME"; then
info "Registering Radicle project '$PROJECT_NAME'..." info "Registering Radicle project '$PROJECT_NAME'..."
@ -116,23 +111,26 @@ else
fi fi
# ╭───────────────────────────────╮ # ╭───────────────────────────────╮
# │ Push Current Branch # │ Push Current Commit Logic
# ╰───────────────────────────────╯ # ╰───────────────────────────────╯
CURRENT_BRANCH=$(git symbolic-ref --short HEAD) CURRENT_BRANCH=$(git symbolic-ref --short HEAD)
if [ ! -f "$RAD_PUSH_FILE" ]; then CURRENT_COMMIT=$(git rev-parse HEAD)
info "Pushing branch '$CURRENT_BRANCH' to Radicle..." LAST_PUSHED_COMMIT=$(cat "$PUSH_STATE_FILE" 2>/dev/null || echo "none")
if git push rad "$CURRENT_BRANCH"; then
touch "$RAD_PUSH_FILE" if [[ "$CURRENT_COMMIT" == "$LAST_PUSHED_COMMIT" ]]; then
info "✓ Branch '$CURRENT_BRANCH' replicated successfully" info "✓ Already pushed commit: $CURRENT_COMMIT"
else
warn "Radicle push failed or already synced"
fi
else else
info "Push previously completed. Skipping." info "Pushing commit '$CURRENT_COMMIT' on branch '$CURRENT_BRANCH'..."
if git push rad "$CURRENT_BRANCH"; then
echo "$CURRENT_COMMIT" > "$PUSH_STATE_FILE"
info "✓ Pushed to Radicle successfully"
else
warn "Push may have failed — check 'rad sync status'"
fi
fi fi
# ╭───────────────────────────────╮ # ╭───────────────────────────────╮
# │ Final Output │ # │ Final Output Block
# ╰───────────────────────────────╯ # ╰───────────────────────────────╯
PROJECT_ID=$(rad self | grep 'Project ID' | awk '{print $NF}' || true) PROJECT_ID=$(rad self | grep 'Project ID' | awk '{print $NF}' || true)
PEER_ID=$(rad self | grep 'Peer ID' | awk '{print $NF}' || true) PEER_ID=$(rad self | grep 'Peer ID' | awk '{print $NF}' || true)