callowayproject / bump-my-version

A small command line tool to simplify releasing software by updating all version strings in your source code by the correct increment and optionally commit and tag the changes.
https://callowayproject.github.io/bump-my-version/
MIT License
305 stars 19 forks source link

Tag and commit still done on error #199

Closed melMass closed 2 months ago

melMass commented 3 months ago

Description

I just integrated bump-my-version as a pre-push to main and one very strange behaviour is that when bmv fails it still commit/tag

What I Did

> git push  
bump-version.............................................................Failed
- hook id: bump-version
- exit code: 1

Usage: bump-my-version bump [OPTIONS] [ARGS]...

 Try 'bump-my-version bump -h' for help
+- Error ---------------------------------------------------------------------+
| Did not find '__version__ = "0.1.4"' in file: '__init__.py'                 |
+-----------------------------------------------------------------------------+

Error during version bump or push: Command '['bump-my-version', 'bump', 'patch']' returned non-zero exit status 2.

> git log                                                                                                                                                                                                 (4⇡) 
commit fd2d26c8e5555ecc2257f91c4a4bd9e011ce6fd4 (HEAD -> main, tag: v0.1.5)
Author: Britney Spears <toxic@spears.com>
Date:   Fri Jun 21 19:57:36 2024 +0200

    ⬆️ Bump version: 0.1.4 → 0.1.5

Is there a flag/option I'm missing to avoid this? If not I'll just chain the commit/tagging myself after bmv so that it's not executed when the later fails.

melMass commented 3 months ago

Ah but the issue with chaining is that I will have to find the value of "new_version"

coordt commented 3 months ago

I'll check into the tagging/committing issue today.

coordt commented 3 months ago

@melMass I need more information since I can't reproduce the error. I created a test at it stops before it gets to the commit and tag part.

Can you include your configuration and add -vv to the bump-my-version call for more verbose information?

melMass commented 3 months ago

Thanks for giving it a look, I'll do a more thoughtful reproduction tomorrow

melMass commented 2 months ago

Sorry for the delay, I'm abandoning the idea of tiding bmv to git hooks as there are multiple layers and it's prone to errors (I had the great idea to experiment with all that on a dirty repo 🤡 , lost a bunch of work).

I will comment here if I ever revisit the idea but after trying I would not recommend it!

Also doing it manually is more logical for me in the end.

Thanks for looking into the issue