callowayproject/bump-my-version

Tag and commit still done on error

Closed this issue · 5 comments

  • bump-my-version version: 0.23.0
  • Python version: 3.9-3.12
  • Operating System: Windows

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.

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

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

@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?

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

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