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