Files
TSYSDevStack/ToolboxStack/collab/git-check.sh
ReachableCEO ab57e3a3a1 feat: Update toolbox-base and template with latest Docker configurations and documentation
\n- Updated Dockerfiles in both toolbox-base and toolbox-template
- Modified build scripts and docker-compose configurations
- Added new audit tools and documentation files
- Created new toolbox-DocStack and toolbox-QADocker implementations
- Updated README and maintenance documentation
2025-10-31 12:46:36 -05:00

54 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Script to check git status and commit changes if needed
# This ensures the ToolboxStack is always in a clean state
set -euo pipefail
# Get the current directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}" && git rev-parse --show-toplevel 2>/dev/null || true)"
# If we can't find the repo root, exit
if [[ -z "${REPO_ROOT}" ]]; then
echo "Error: Unable to find git repository root" >&2
exit 1
fi
# Change to the repo root
cd "${REPO_ROOT}"
# Check if there are any changes
if ! git diff --quiet --ignore-submodules --exit-code; then
echo "Git working tree has uncommitted changes. Committing..."
# Add all changes
git add .
# Create a commit message
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
# Try to get a meaningful commit message based on changed files
CHANGED_FILES=$(git diff --name-only HEAD | head -10)
if [[ -n "${CHANGED_FILES}" ]]; then
COMMIT_MSG="chore(toolboxstack): Auto-commit changes at ${TIMESTAMP}"
else
COMMIT_MSG="chore(toolboxstack): Periodic update at ${TIMESTAMP}"
fi
# Commit the changes
if git commit -m "${COMMIT_MSG}"; then
echo "Successfully committed changes"
else
echo "Failed to commit changes" >&2
exit 1
fi
else
echo "Git working tree is clean. No changes to commit."
fi
# Check if we need to push
# (This would require checking if the local branch is ahead of the remote)
# For now, we'll just inform the user
echo "Git status check completed."