Implements full MeshDD-Bot with TCP connection to Meshtastic devices, SQLite storage for nodes/messages, aiohttp web dashboard with WebSocket live updates, and Leaflet.js map view with color-coded node markers. Includes bot commands (!ping, !nodes, !info, !help, !weather, !stats, !uptime) and automatic version bumping via pre-commit hook. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
73 lines
1.8 KiB
Bash
Executable file
73 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
# Git pre-commit hook: Auto-increment patch version, optional minor bump
|
|
# Install: cp scripts/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
|
|
|
|
VERSION_FILE="meshbot/version.py"
|
|
CHANGELOG_FILE="CHANGELOG.md"
|
|
|
|
if [ ! -f "$VERSION_FILE" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Read current version
|
|
MAJOR=$(grep "^MAJOR" "$VERSION_FILE" | awk -F'= ' '{print $2}')
|
|
MINOR=$(grep "^MINOR" "$VERSION_FILE" | awk -F'= ' '{print $2}')
|
|
PATCH=$(grep "^PATCH" "$VERSION_FILE" | awk -F'= ' '{print $2}')
|
|
|
|
echo "Current version: $MAJOR.$MINOR.$PATCH"
|
|
|
|
# Ask for minor bump (only if interactive terminal)
|
|
if [ -t 0 ]; then
|
|
read -p "Minor-Version erhöhen? (y/N) " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
MINOR=$((MINOR + 1))
|
|
PATCH=0
|
|
else
|
|
PATCH=$((PATCH + 1))
|
|
fi
|
|
else
|
|
PATCH=$((PATCH + 1))
|
|
fi
|
|
|
|
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
|
|
echo "New version: $NEW_VERSION"
|
|
|
|
# Update version.py
|
|
cat > "$VERSION_FILE" << EOF
|
|
MAJOR = $MAJOR
|
|
MINOR = $MINOR
|
|
PATCH = $PATCH
|
|
|
|
VERSION = f"{MAJOR}.{MINOR}.{PATCH}"
|
|
EOF
|
|
|
|
# Update CHANGELOG.md - add entry after first "## " line
|
|
DATE=$(date +%Y-%m-%d)
|
|
COMMIT_MSG=$(git log --format=%B -1 HEAD 2>/dev/null || echo "Update")
|
|
|
|
# Get staged files for changelog context
|
|
STAGED_FILES=$(git diff --cached --name-only)
|
|
|
|
# Add changelog entry
|
|
TEMP_FILE=$(mktemp)
|
|
HEADER_DONE=false
|
|
|
|
while IFS= read -r line; do
|
|
echo "$line" >> "$TEMP_FILE"
|
|
if [[ "$line" == "# Changelog" ]] && [ "$HEADER_DONE" = false ]; then
|
|
echo "" >> "$TEMP_FILE"
|
|
echo "## [$NEW_VERSION] - $DATE" >> "$TEMP_FILE"
|
|
echo "### Changed" >> "$TEMP_FILE"
|
|
echo "- Auto-commit update" >> "$TEMP_FILE"
|
|
HEADER_DONE=true
|
|
fi
|
|
done < "$CHANGELOG_FILE"
|
|
|
|
mv "$TEMP_FILE" "$CHANGELOG_FILE"
|
|
|
|
# Stage updated files
|
|
git add "$VERSION_FILE" "$CHANGELOG_FILE"
|
|
|
|
echo "Version updated to $NEW_VERSION"
|