Skip to content

Commit a4adfa4

Browse files
committed
fix(bump.py): CHANGELOG.md gets git added and commited correctly
The elements in `version_files` may contain not only a file path, but also a regex after a colon. Thus make sure to only pass the file path to `git add`.
1 parent 5bf5106 commit a4adfa4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

commitizen/commands/bump.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@ def __call__(self): # noqa: C901
203203
},
204204
)
205205
changelog_cmd()
206-
c = cmd.run(f"git add {changelog_cmd.file_name} {' '.join(version_files)}")
206+
git_add_changelog_and_version_files_command = (
207+
f"git add {changelog_cmd.file_name} "
208+
f"{' '.join(file_name.partition(':')[0] for file_name in version_files)}"
209+
)
210+
c = cmd.run(git_add_changelog_and_version_files_command)
207211

208212
# Do not perform operations over files or git.
209213
if dry_run:
@@ -226,7 +230,7 @@ def __call__(self): # noqa: C901
226230
# Maybe pre-commit reformatted some files? Retry once
227231
logger.debug("1st git.commit error: %s", c.err)
228232
logger.info("1st commit attempt failed; retrying once")
229-
cmd.run(f"git add {changelog_cmd.file_name} {' '.join(version_files)}")
233+
cmd.run(git_add_changelog_and_version_files_command)
230234
c = git.commit(message, args=self._get_commit_args())
231235
if c.return_code != 0:
232236
raise BumpCommitFailedError(f'2nd git.commit error: "{c.err.strip()}"')

0 commit comments

Comments
 (0)