Updated script to auto exit after 10 seconds
This commit is contained in:
parent
7a2976f99e
commit
acb1053f07
1 changed files with 18 additions and 8 deletions
|
|
@ -12,6 +12,15 @@
|
|||
|
||||
set -uo pipefail
|
||||
|
||||
# Auto-exit helper function: sleeps 10 seconds and exits
|
||||
auto_exit() {
|
||||
local status="${1:-0}"
|
||||
echo ""
|
||||
echo "Closing terminal window in 10 seconds..."
|
||||
sleep 10
|
||||
exit "$status"
|
||||
}
|
||||
|
||||
PROJECTS_ROOT="/export/kingdezignsnas-16/Public/07 - Projects"
|
||||
|
||||
declare -A FOLDER_MAP=(
|
||||
|
|
@ -33,35 +42,35 @@ FOLDER="${FOLDER_MAP[$SELECTION]:-}"
|
|||
|
||||
if [ -z "$FOLDER" ]; then
|
||||
echo "Invalid selection. Exiting."
|
||||
exit 1
|
||||
auto_exit 1
|
||||
fi
|
||||
|
||||
REPO_PATH="$PROJECTS_ROOT/$FOLDER"
|
||||
|
||||
if [ ! -d "$REPO_PATH" ]; then
|
||||
echo "ERROR: Folder not found at: $REPO_PATH"
|
||||
exit 1
|
||||
auto_exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$REPO_PATH/.git" ]; then
|
||||
echo "ERROR: '$FOLDER' is not yet a git repository (no .git found)."
|
||||
echo "This folder needs one-time setup first — create the org/repo in"
|
||||
echo "Forgejo, then run: git init && git remote add origin <url>"
|
||||
exit 1
|
||||
auto_exit 1
|
||||
fi
|
||||
|
||||
cd "$REPO_PATH" || exit 1
|
||||
cd "$REPO_PATH" || auto_exit 1
|
||||
|
||||
echo ""
|
||||
echo "Pulling latest changes for $FOLDER..."
|
||||
if ! git pull --no-edit; then
|
||||
echo "ERROR: git pull failed — likely a conflict. Resolve manually before continuing."
|
||||
exit 1
|
||||
auto_exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
echo "No changes detected in $FOLDER. Nothing to commit."
|
||||
exit 0
|
||||
auto_exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
|
@ -73,7 +82,7 @@ read -rp "Enter a description for this change: " DESCRIPTION
|
|||
|
||||
if [ -z "$DESCRIPTION" ]; then
|
||||
echo "A description is required. Exiting without committing."
|
||||
exit 1
|
||||
auto_exit 1
|
||||
fi
|
||||
|
||||
git add -A
|
||||
|
|
@ -84,9 +93,10 @@ echo "Pushing to Forgejo..."
|
|||
if git push origin main; then
|
||||
echo ""
|
||||
echo "SUCCESS: $FOLDER updated and pushed."
|
||||
auto_exit 0
|
||||
else
|
||||
echo ""
|
||||
echo "ERROR: push failed. Your commit was saved locally — retry with:"
|
||||
echo " cd \"$REPO_PATH\" && git push origin main"
|
||||
exit 1
|
||||
auto_exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue