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,10 +15,10 @@ RAD_KEYS="$RAD_HOME/keys.json"
RAD_BACKUP=".radicle-backup/keys.json"
RAD_PATH_LINE='export PATH="$HOME/.radicle/bin:$PATH"'
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 $*"; }
warn() { echo -e "\e[1;33m[WARN]\e[0m $*"; }
@ -44,7 +44,7 @@ EMAIL=$(git config --global user.email || true)
info "Git identity: $(git config --global user.name) <$(git config --global user.email)>"
# ╭───────────────────────────────╮
# │ Install Radicle CLI │
# │ Radicle CLI Setup
# ╰───────────────────────────────╯
if [ ! -x "$RAD_BIN" ]; then
info "Installing Radicle CLI..."
@ -52,19 +52,14 @@ if [ ! -x "$RAD_BIN" ]; then
curl -sSf https://radicle.xyz/install | sh || error "Radicle install failed"
fi
# ─ PATH Setup (Temporary + Persistent)
if ! command -v rad &>/dev/null; then
export PATH="$HOME/.radicle/bin:$PATH"
info "→ Temporarily patched PATH for this session"
fi
export PATH="$HOME/.radicle/bin:$PATH"
if ! grep -Fxq "$RAD_PATH_LINE" "$PROFILE_FILE"; then
echo "$RAD_PATH_LINE" >> "$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
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)"
@ -88,14 +83,14 @@ fi
# ╭───────────────────────────────╮
# │ Start Rad Node │
# ╰───────────────────────────────╯
pgrep -f "rad node start" &>/dev/null || {
pgrep -f "rad node start" >/dev/null || {
info "Starting Radicle node..."
nohup rad node start > /dev/null 2>&1 &
sleep 3
}
# ╭───────────────────────────────╮
# │ Initialize Git Repo
# │ Git Repo Initialization
# ╰───────────────────────────────╯
if [ ! -d .git ]; then
git init
@ -106,7 +101,7 @@ else
fi
# ╭───────────────────────────────╮
# │ Register Radicle Project
# │ Radicle Project Registration
# ╰───────────────────────────────╯
if ! rad projects | grep -q "$PROJECT_NAME"; then
info "Registering Radicle project '$PROJECT_NAME'..."
@ -116,23 +111,26 @@ else
fi
# ╭───────────────────────────────╮
# │ Push Current Branch
# │ Push Current Commit Logic
# ╰───────────────────────────────╯
CURRENT_BRANCH=$(git symbolic-ref --short HEAD)
if [ ! -f "$RAD_PUSH_FILE" ]; then
info "Pushing branch '$CURRENT_BRANCH' to Radicle..."
if git push rad "$CURRENT_BRANCH"; then
touch "$RAD_PUSH_FILE"
info "✓ Branch '$CURRENT_BRANCH' replicated successfully"
else
warn "Radicle push failed or already synced"
fi
CURRENT_COMMIT=$(git rev-parse HEAD)
LAST_PUSHED_COMMIT=$(cat "$PUSH_STATE_FILE" 2>/dev/null || echo "none")
if [[ "$CURRENT_COMMIT" == "$LAST_PUSHED_COMMIT" ]]; then
info "✓ Already pushed commit: $CURRENT_COMMIT"
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
# ╭───────────────────────────────╮
# │ Final Output │
# │ Final Output Block
# ╰───────────────────────────────╯
PROJECT_ID=$(rad self | grep 'Project ID' | awk '{print $NF}' || true)
PEER_ID=$(rad self | grep 'Peer ID' | awk '{print $NF}' || true)