#!/bin/bash # Script to manually commit with changelog content # This avoids the complexity and risks of git hooks set -e echo "๐Ÿ”„ Manual commit with changelog..." # Check if CHANGELOG.md exists and has content if [ ! -f "CHANGELOG.md" ] || [ ! -s "CHANGELOG.md" ]; then echo "โŒ No CHANGELOG.md content found. Please add your changes first." exit 1 fi # Check if there are staged changes if [ -z "$(git diff --cached --name-only)" ]; then echo "โŒ No staged changes found. Please stage your changes first with 'git add'." exit 1 fi # Create a temporary file for the commit message TEMP_MSG=$(mktemp) # Get the commit message from user input echo "Enter your commit message (or press Enter for default):" read -r user_message if [ -z "$user_message" ]; then user_message="Update" fi echo "$user_message" > "$TEMP_MSG" # Add a separator echo "" >> "$TEMP_MSG" echo "---" >> "$TEMP_MSG" echo "Session Changes:" >> "$TEMP_MSG" echo "" >> "$TEMP_MSG" # Add the CHANGELOG.md content (excluding the header) grep -v "^#" CHANGELOG.md | grep -v "^$" >> "$TEMP_MSG" # Commit with the combined message git commit -F "$TEMP_MSG" # Clean up temp file rm "$TEMP_MSG" echo "โœ… Commit completed with changelog content" # Clear the CHANGELOG.md file echo "# apt-ostree Changelog" > CHANGELOG.md echo "" >> CHANGELOG.md echo "## Current Session Changes" >> CHANGELOG.md echo "" >> CHANGELOG.md echo "Add your changes here during development..." >> CHANGELOG.md # Stage and commit the cleared changelog git add CHANGELOG.md git commit -m "chore: clear changelog for next session" echo "๐Ÿงน CHANGELOG.md cleared for next session" echo "โœ… All done!"