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
349 stars 21 forks source link

Support commit flag when running bump-my-version with an external config file #216

Closed abarri closed 3 months ago

abarri commented 3 months ago

Description

I have my configuration stored in an external bumpversion.toml file, so that I can use it across multiple repositories. In these repositories, I run bump-my-version with --config-file=/path_to_external/bumpversion.toml.

What I Did

When I set the commit flag, bump-my-version tries to stage the external config file resulting in a git error.

For example:

bump-my-version bump patch pyproject.toml --config-file=/path_to_external/bumpversion.toml --commit --verbose

returns the following logs:

...
Processing config file: /path_to_external/bumpversion.toml                                                                        
Preparing Git commit                                                                                                                                                                          
  Adding changes in file '/path_to_external/bumpversion.toml' to Git                                                              
fatal: : /path_to_external/bumpversion.toml: ': /path_to_external/bumpversion.toml' is outside repository at '/path_to_repo'
...

Proposal

First check if a config file is outside the git repo before trying to stage it.