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

Provide an option to ignore paths #184

Closed fmigneault closed 6 months ago

fmigneault commented 6 months ago

Description

Provided that a glob pattern can be used to look "everywhere", bump-my-version loses time looking up many irrelevant locations. This makes it harder to inspect --dry-run --verbose outputs due to the amount of paths crawled. An ignore or exclude configuration option would help preemptively ignore many known paths. Ideally, a list of patterns would be supported so that we can specify for example:

[tool.bumpversion]
ignore = [
  "node_modules/",
  "build/",
  "dist/",
]

What I Did

Example config that looks for a very specific pattern anywhere in the repository:

[tool.bumpversion]
current_version = "1.0.0"
ignore_missing_version = true
ignore_missing_files = false

[[tool.bumpversion.files]]
glob = "**/*.json"
search = "https://crim-ca.github.io/mlm-extension/v{current_version}/schema.json"
replace = "https://crim-ca.github.io/mlm-extension/v{new_version}/schema.json"

Using --verbose quickly highlights a massive list of "unmatched files" (as expected) in loads of node_modules, temporary build dirs, etc.

The current alternative is to list more specific nested directories (e.g.: src/**/*.json), but all locations might not be known in advance, and causes many [[tool.bumpversion.files]] to be duplicated of each sub-dir to support.