devlog 7.
I noticed I’m forgetting to update Xvc CHANGELOG. I added a pre-push hook to check the files I’m pushing and if CHANGELOG is not among them, it breaks the push. I hope this will help me to update the logs more often.
#!/bin/bash
# Git pre-push hook to check if CHANGELOG.md is included in the push and if the branch is develop
# Get the current branch name
current_branch=$(git rev-parse --abbrev-ref HEAD)
# Check if the branch is develop
if [ "$current_branch" == "main" ]; then
echo "You are on the main branch. Skipping CHANGELOG.md check."
exit 0
fi
# remote="$1"
# url="$2"
# Get the list of commits to be pushed
commits=$(git rev-list '@{u}..HEAD')
has_rust_files=$(false)
# TODO: We can iterate to get file list only once
# Get the list of files that are going to be pushed
for commit in $commits; do
if git diff-tree --no-commit-id --name-only -r "${commit}" | grep -q "\\.rs$"; then
has_rust_files=$(true)
fi
done
if [[ ! $has_rust_files ]]; then
echo "No .rs files in the push, no need to check CHANGELOG"
exit 0
fi
# Check if CHANGELOG.md is among the files in the commits
for commit in $commits; do
if git diff-tree --no-commit-id --name-only -r "${commit}" | grep -q "CHANGELOG.md"; then
echo "CHANGELOG.md is included in the push."
exit 0
fi
done
echo "ERROR: CHANGELOG.md is not included in the push."
exit 1
Edit: 2025-02-08: Added a check when only the code files are changed.