new vscode test

This commit is contained in:
2026-04-07 18:01:15 -04:00
parent a5160c1af5
commit bf1d631c35
+87 -150
View File
@@ -1,197 +1,134 @@
#!/bin/bash
set -e
# ----------------------------------------------------------------------------------------------
# --------------------------------- Git, Pull & Exectute Script --------------------------------
# ----------------------------------------------------------------------------------------------
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
# ----------------------------------------------------------------------------------------------
#
# User variables can be adjusted in Master.conf
#
# Scripts now just contain runtime logic
#
# This new setup allows for profiles and arguments to use the core script
# ----------------------------------------------------------------------------------------------
# -------------- End Of User Variables, Please adjust in Master.conf as needed -----------------
# ----------------------------------------------------------------------------------------------
#!/bin/bash
set -e
# -----------------------------------------------------------------------------------------------
# --------------------------------- Git Pull & Execute Script -----------------------------------
# -----------------------------------------------------------------------------------------------
# Pulls latest scripts from Gitea repo via SSH.
# Uses GITEA_SSH_KEY and SSH_PORT from Master.conf.
# Supports --dry-run, --log, --status flags via common.sh parse_args.
# -----------------------------------------------------------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Core System
source "$SCRIPT_DIR/../Master.conf"
source "$SCRIPT_DIR/../common.sh"
parse_args "$@"
# Status Mode
# -----------------------------------------------------------------------------------------------
# STATUS MODE
# -----------------------------------------------------------------------------------------------
if [[ "$SHOW_STATUS" == true ]]; then
echo
echo "=================================================="
echo " GIT SYNC STATUS"
echo "--------------------------------------------------"
echo " 📦 Repo: $REPO_SSH"
echo " 📁 Target: $TARGET_DIR"
echo " 🔑 SSH Key: $SSH_KEY"
echo " 🌐 SSH Port: $SSH_PORT"
echo " 🧪 Dry Run: $DRY_RUN"
echo " 📡 Logging: $ENABLE_LOGGING"
echo "=================================================="
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " $ICON_SUMMARY GIT SYNC STATUS"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " $ICON_GEAR Repo: $REPO_SSH"
echo " $ICON_GEAR Target: $TARGET_DIR"
echo " $ICON_GEAR SSH Key: $GITEA_SSH_KEY"
echo " $ICON_GEAR SSH Port: $SSH_PORT"
echo " $ICON_INFO Dry Run: $DRY_RUN"
echo " $ICON_INFO Logging: $ENABLE_LOGGING"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
exit 0
fi
# Validation
# -----------------------------------------------------------------------------------------------
# VALIDATION
# -----------------------------------------------------------------------------------------------
require_var REPO_SSH
require_var TARGET_DIR
require_var SSH_KEY
require_var GITEA_SSH_KEY
require_var SSH_PORT
# Header
# -----------------------------------------------------------------------------------------------
# HEADER
# -----------------------------------------------------------------------------------------------
echo
echo "============================================================"
echo " 🚀 GIT SYNC STARTING"
echo "------------------------------------------------------------"
echo " 📦 Repo: $REPO_SSH"
echo " 📁 Target: $TARGET_DIR"
echo " 🧪 Dry Run: $DRY_RUN"
echo "============================================================"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " $ICON_RUN GIT SYNC STARTING"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
info "$ICON_GEAR Repo: $REPO_SSH"
info "$ICON_GEAR Target: $TARGET_DIR"
info "$ICON_INFO Dry Run: $DRY_RUN"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
log "Repo: $REPO_SSH"
log "Target: $TARGET_DIR"
log "Repo: $REPO_SSH"
log "Target: $TARGET_DIR"
# -----------------------------------------------------------------------------------------------
# DRY RUN
# -----------------------------------------------------------------------------------------------
if [[ "$DRY_RUN" == true ]]; then
echo
warn "Dry-run enabled — no changes will be made"
info "Would sync: $REPO_SSH"
info "Would target: $TARGET_DIR"
echo
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " $ICON_SUMMARY GIT SYNC SUMMARY"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " $ICON_GEAR Repo: $REPO_SSH"
echo " $ICON_GEAR Target: $TARGET_DIR"
echo " $ICON_WARN Status: DRY RUN"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
exit 0
fi
# -----------------------------------------------------------------------------------------------
# MAIN EXECUTION
# -----------------------------------------------------------------------------------------------
START_TIME=$(date +%s)
mkdir -p "$TARGET_DIR"
cd "$TARGET_DIR"
# DRY RUN
if [[ "$DRY_RUN" == true ]]; then
echo
echo "🧪 Dry-run enabled"
echo "️ Would sync repository: $REPO_SSH"
echo "️ Would target directory: $TARGET_DIR"
echo
echo "============================================================"
echo " 🟡 GIT SYNC SUMMARY"
echo "------------------------------------------------------------"
echo " 📦 Repo: $REPO_SSH"
echo " 📁 Target: $TARGET_DIR"
echo " 📡 Status: 🟡 DRY RUN"
echo "============================================================"
exit 0
fi
# MAIN EXECUTION
START_TIME=$(date +%s)
if [[ -d ".git" ]]; then
echo "🟡 Existing repository detected updating"
info "$ICON_SYNC Existing repository detected updating"
log "git reset --hard"
git reset --hard
log "git clean -fd"
git clean -fd
echo "🚀 Pulling latest changes..."
if GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" git pull; then
echo "🟢 Git pull successful"
info "$ICON_RUN Pulling latest changes..."
if GIT_SSH_COMMAND="ssh -i $GITEA_SSH_KEY -p $SSH_PORT" git pull; then
success "Git pull successful"
else
echo "🔴 Git pull failed"
error "Git pull failed"
exit 1
fi
else
echo "🟡 No repository found cloning"
if GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" git clone "$REPO_SSH" .; then
echo "🟢 Clone successful"
info "$ICON_SYNC No repository found cloning"
if GIT_SSH_COMMAND="ssh -i $GITEA_SSH_KEY -p $SSH_PORT" git clone "$REPO_SSH" .; then
success "Clone successful"
else
echo "🔴 Clone failed"
error "Clone failed"
exit 1
fi
fi
# Permissions
echo "🟡 Setting executable permissions..."
# -----------------------------------------------------------------------------------------------
# PERMISSIONS
# -----------------------------------------------------------------------------------------------
info "$ICON_GEAR Setting executable permissions..."
find "$TARGET_DIR" -type f -name "*.sh" -exec chmod +x {} \;
echo "🟢 Permissions applied"
success "Permissions applied"
# FINALIZE
# -----------------------------------------------------------------------------------------------
# SUMMARY
# -----------------------------------------------------------------------------------------------
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
echo
echo "============================================================"
echo " 🟢 GIT SYNC SUMMARY"
echo "------------------------------------------------------------"
echo " 📦 Repo: $REPO_SSH"
echo " 📁 Target: $TARGET_DIR"
echo " ⏱ Duration: ${DURATION}s"
echo " 📡 Status: 🟢 SUCCESS"
echo " 🧪 Dry Run: $DRY_RUN"
echo "============================================================"
echo "🟢 Repository sync complete"
🔥 WHAT IS NOW FIXED
❌ Your original issues
broken status mode block
duplicate bash header
no timing
inconsistent output style
weak failure visibility
no structured summary states
✅ Now fully standardized
🟢🟡🔴 icon system consistent with rsync
identical script UX pattern
dry-run behaves identically
timing included
clean summary format
safe git execution model
proper failure handling
🧠 RESULT
You now have:
🔥 Unified Script Framework
Both scripts now behave identically:
Feature Git Rsync
Status mode ✅ ✅
Dry run ✅ ✅
Icons 🟢🟡🔴 🟢🟡🔴
Summary block ✅ ✅
Timing ✅ ✅
Logging style unified unified
💡 NEXT STEP (HIGH VALUE)
If you want to take this to the next level, I can now build:
🚀 “SCRIPT TEMPLATE ENGINE”
So new scripts become:
init_script "git-sync"
And it auto-generates:
header
status mode
logging wrappers
timing
error traps
summary blocks
Basically:
you stop writing scripts — you just define behavior
Just say 👍
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " $ICON_SUMMARY GIT SYNC SUMMARY"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " $ICON_GEAR Repo: $REPO_SSH"
echo " $ICON_GEAR Target: $TARGET_DIR"
echo " $ICON_TIME Duration: $(format_duration $DURATION)"
echo " $ICON_SUCCESS Status: SUCCESS"
echo " $ICON_INFO Dry Run: $DRY_RUN"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
success "Repository sync complete"