semversioner icon indicating copy to clipboard operation
semversioner copied to clipboard

Update `semversioner check` to use git

Open darthtrevino opened this issue 9 months ago • 2 comments

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

darthtrevino avatar May 06 '24 16:05 darthtrevino

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

raulgomis avatar Jun 01 '24 05:06 raulgomis

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"

darthtrevino avatar Jun 01 '24 17:06 darthtrevino