semversioner
semversioner copied to clipboard
Update `semversioner check` to use git
This PR updates the check
command to interact with git to ensure that there is a change-document for the current branch if any impacted files are touched.
Fixes #48
Hi @darthtrevino , thanks for this idea and code contribution.
For now, I wouldn't like to couple this tool with any version control system in order to keep things simple and tool agnostic. I guess you could run the git diff external to the tool, can't you?
Cheers, Raul
Sure, I can do that, but the check
command is kind of pointless when it's not tied to a VCS. Here's a script I'm using in another project. One of my hopes here is that this tool can evolve to a state where it handles boilerplate like this.
#!/bin/sh
changes=$(git diff --name-only origin/main)
has_change_doc=$(echo $changes | grep .semversioner/next-release)
has_impacting_changes=$(echo $changes | grep my-project)
if [ "$has_impacting_changes" ] && [ -z "$has_change_doc" ]; then
echo "Check failed. Run 'poetry run semversioner add-change' to update the next release version"
exit 1
fi
echo "OK"