Skip to content

fix: add --extra-files flag to stage additional files in bump commit#284

Open
maimul wants to merge 1 commit into
c4urself:masterfrom
maimul:fix/259-extra-files
Open

fix: add --extra-files flag to stage additional files in bump commit#284
maimul wants to merge 1 commit into
c4urself:masterfrom
maimul:fix/259-extra-files

Conversation

@maimul

@maimul maimul commented May 30, 2026

Copy link
Copy Markdown

Problem

There is no way to include generated files (changelogs, build artifacts, lockfiles) in the version bump commit when those files are not part of any [bumpversion:file:...] section. Users are forced to make a separate commit or use --allow-dirty.

Fix

Add --extra-files FILE [FILE ...] CLI flag (also settable as extra_files = ... in config) that stages arbitrary additional files alongside the bump commit. Files can be dirty or untracked.

Changes

cli.py

  • extra_files added to the list-value parsing loop in _load_configuration
  • --extra-files argument added to _parse_arguments_phase_2
  • _determine_vcs_dirty accepts extra_files=None and passes them to assert_nondirty as allowed_paths so the dirty check doesn't abort when extra files are modified
  • _commit_to_vcs accepts extra_files=None and calls vcs.add_extra_path() for each before committing

vcs.py

  • Git.assert_nondirty accepts allowed_paths=None; paths in that set are excluded from the dirty check
  • Git.add_extra_path uses git add <path> (without --update) so untracked files can be staged
  • BaseVCS.add_extra_path is a no-op so Mercurial doesn't break

Usage

bumpversion patch --extra-files docs/changelog.md dist/summary.txt

Or in config:

[bumpversion]
extra_files = docs/changelog.md
              dist/summary.txt

Fixes #259

…4urself#259)

When committing a version bump, it was not possible to include generated
files (changelogs, build artifacts) that weren't modified by bumpversion
itself. This adds --extra-files (repeatable, or space-separated in config)
which stages arbitrary files alongside the bump commit.

Changes:
- cli.py: parse extra_files from config (list value) and --extra-files flag
- cli.py: pass extra_files through _determine_vcs_dirty so dirty-check
  ignores those paths, and through _commit_to_vcs to stage them
- vcs.py: Git.assert_nondirty accepts allowed_paths to skip extra files
- vcs.py: Git.add_extra_path uses `git add` (not --update) so untracked
  files can be included; BaseVCS.add_extra_path is a no-op

Fixes c4urself#259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow certain files to be dirty

1 participant