Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ignore missing file option #138

Merged
merged 6 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ instance/
# Scrapy stuff:
.scrapy

# Sphinx documentation
docs
docsrc/_build/
docsrc/_autosummary

# PyBuilder
.pybuilder/
target/
Expand Down
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ repos:
- id: check-symlinks
- id: check-toml
- id: check-yaml
exclude: test.*
exclude: |
(?x)^(
test.*|
mkdocs.yml
)$
args: [--allow-multiple-documents]
- id: debug-statements
- id: end-of-file-fixer
Expand Down
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fix encoding when reading text. [c03476a](https://github.com/callowayproject/bump-my-version/commit/c03476ac51b94cd136c39bb9c48fee4f1a815b42)

Fixes #68

### Other

- [pre-commit.ci] pre-commit autoupdate. [491b4aa](https://github.com/callowayproject/bump-my-version/commit/491b4aa4edc0241edbf5d77cfcf609c6de56f301)
Expand All @@ -25,6 +26,7 @@
- Refactored VersionComponentConfig to VersionComponentSpec. [b538308](https://github.com/callowayproject/bump-my-version/commit/b53830826c81446576b3979080b05930d71c34e2)

More consistent with VersionSpec

### New

- Added mental model documentation. [5cbd250](https://github.com/callowayproject/bump-my-version/commit/5cbd250ab412f0f56af14a0fcc450cb31643e3e4)
Expand Down Expand Up @@ -97,6 +99,7 @@
- Refactored the create subcommand. [f529d28](https://github.com/callowayproject/bump-my-version/commit/f529d283fb3a32eddee9daf368f9ce17ba5efcf1)

- Also organized the CLI tests

### New

- Added `show-bump` subcommand. [0bbd814](https://github.com/callowayproject/bump-my-version/commit/0bbd81489ea0484962e9b3c207e6c6860cab6c55)
Expand All @@ -105,6 +108,7 @@
- Added sample-config feature. [3d0f67d](https://github.com/callowayproject/bump-my-version/commit/3d0f67dbf9f42ffad1583e1fe08bd0971262257c)

- Initial implementation

### Updates

- Updated documentation. [4f90348](https://github.com/callowayproject/bump-my-version/commit/4f903486338af31557c3647fc0ae00d7cc8e4213)
Expand All @@ -122,6 +126,7 @@
- Removed dotted-notation from requirements. There is an issue on how dotted-notation sets values in the TOMLkit data structure.

- Added `get_nested_value` and `set_nested_value` as replacements for dotted-notation.

### Other

- [pre-commit.ci] pre-commit autoupdate. [ee4d2f3](https://github.com/callowayproject/bump-my-version/commit/ee4d2f32af28c650651b9242c09e3b125e0101e2)
Expand Down Expand Up @@ -184,6 +189,7 @@
- Fixed regression in config update. [2bbbd74](https://github.com/callowayproject/bump-my-version/commit/2bbbd74fe4b80895b3719692d1fe0023cc388bbb)

Fixes #108

### New

- Added a test case for line-start regexes. [ef4823c](https://github.com/callowayproject/bump-my-version/commit/ef4823c0cdb92660439095aacdbac6801953e4ae)
Expand Down Expand Up @@ -297,6 +303,7 @@
- Added key_path to FileConfig. [e160b40](https://github.com/callowayproject/bump-my-version/commit/e160b401b0d14cef77255bbd87748721db4e2e3d)

- Also made all attributes required except `filename`, `glob`, and `key_path`

### Other

- [pre-commit.ci] auto fixes from pre-commit.com hooks. [8188a42](https://github.com/callowayproject/bump-my-version/commit/8188a42d1e25efab1f45499b448f2c007738cbbe)
Expand Down Expand Up @@ -343,6 +350,7 @@
- Add -h for help option. [fda71b0](https://github.com/callowayproject/bump-my-version/commit/fda71b0fce4115514fa85cf1d627e5f3673dba66)

Fixes #67

### Other

- Drop Python3.7 as compatible version. [890edc8](https://github.com/callowayproject/bump-my-version/commit/890edc8a0c0911ad3696a9bc0ddca7a9a72c5afd)
Expand Down Expand Up @@ -373,6 +381,7 @@

- Changed the flags to --regex/--no-regex
- updated tests and docs

## 0.11.0 (2023-09-26)
[Compare the full difference.](https://github.com/callowayproject/bump-my-version/compare/0.10.0...0.11.0)

Expand Down Expand Up @@ -516,6 +525,7 @@
- The `--search` and `--replace` options now completely override any other search and replace logic.

Fixes #34

### Other

- [pre-commit.ci] pre-commit autoupdate. [531738d](https://github.com/callowayproject/bump-my-version/commit/531738d62d3a2583c7831d17151cb8ae7b14677c)
Expand All @@ -540,6 +550,7 @@

- Declared SourceCodeManager attributes as `ClassVar[List[str]]`
- `_TEST_USABLE_COMMAND`, `_COMMIT_COMMAND`, and `_ALL_TAGS_COMMAND` affected

### New

- Added tests for CLI replace command. [a53cddc](https://github.com/callowayproject/bump-my-version/commit/a53cddc3c13bb21f5432d1cd331a51027a25981f)
Expand All @@ -559,6 +570,7 @@
- `short_branch_name` is the branch name, lower case, containing only a-z and 0-9, and truncated to 20 characters.

Fixes #28

### Other

- Check config before tagging. [3a6e3ee](https://github.com/callowayproject/bump-my-version/commit/3a6e3eebdbc16ae509754fd977625a4c9b19d82a)
Expand Down Expand Up @@ -586,6 +598,7 @@

- `tomlkit.parse()` returns a `TOMLDocument`.
- `unwrap()` converts it into a `dict`

### New

- Adds `branch_name` to SCM information. [173be1a](https://github.com/callowayproject/bump-my-version/commit/173be1a7a107639be912d0fb76149accb54b0332)
Expand All @@ -602,6 +615,7 @@
- Can output in YAML, JSON, and default
- Can specify one or more items to display
- Can use dotted-notation to pull items from nested data structures.

### Updates

- Changes bump-my-version into subcommands. [31ffbcf](https://github.com/callowayproject/bump-my-version/commit/31ffbcf839e2491c31d90b51041d1e840371108f)
Expand All @@ -619,6 +633,7 @@

- Fixes issue #20
- Renders the correct `current_version` for each file being modified.

### Other

- [pre-commit.ci] auto fixes from pre-commit.com hooks. [5476cdf](https://github.com/callowayproject/bump-my-version/commit/5476cdf8b66666e06e9bfd4d71eaf2610103079a)
Expand Down Expand Up @@ -646,12 +661,14 @@
- Added documentation for replacing strings in different files. [893ec03](https://github.com/callowayproject/bump-my-version/commit/893ec03f6ceaf2a050c31f10006aa63c0411af4e)

Fixes #6

### Other

- Made `VERSION_PART` optional. [f236b7d](https://github.com/callowayproject/bump-my-version/commit/f236b7de94d9f58e493c617848e3eb02e85a24c7)

- Fixes #16
- `VERSION_PART` is detected from the arguments based on the configuration

### Updates

- Updated docs indicated VERSION_PART is optional. [22edeac](https://github.com/callowayproject/bump-my-version/commit/22edeac9018e75f79d7167fbfc6ca56cda4d3b07)
Expand All @@ -673,6 +690,7 @@
- Fixes release.yaml. [01870d5](https://github.com/callowayproject/bump-my-version/commit/01870d5878b5f0a6e601863c4b9c25572db6cbb0)

Outputs the notes to a file instead of an environment variable.

### Other

- [pre-commit.ci] auto fixes from pre-commit.com hooks. [266002f](https://github.com/callowayproject/bump-my-version/commit/266002f4d60ed6fe3623ba5f713318dc6220ec00)
Expand Down Expand Up @@ -708,6 +726,7 @@
- Fixes test package. [7c12072](https://github.com/callowayproject/bump-my-version/commit/7c12072b11938385ec81c5e9cd285d91ac1c00d7)

- The build-and-inspect action didn't save the dist packages

### New

- Added tests for logging branches. [f8f0278](https://github.com/callowayproject/bump-my-version/commit/f8f027846349df4c66377c2cf4cc6903cd1f9bf7)
Expand Down Expand Up @@ -757,6 +776,7 @@

- changed name to bump-my-version in setup.cfg
- added PAT in release pipeline to (hopefully) allow committing and tagging to master without issue.

### New

- Added codecov to workflow. [a5009e0](https://github.com/callowayproject/bump-my-version/commit/a5009e04068787bb98363c3e6803f84a338ee798)
Expand Down Expand Up @@ -804,10 +824,12 @@

- Added bumpversion.yaml to increase the version when a PR is closed

- Added release.yaml to create a github relase and upload things to PyPI
- Added release.yaml to create a github release and upload things to PyPI

- Added PYTHONUTF8 mode. [91a73e2](https://github.com/callowayproject/bump-my-version/commit/91a73e26af94185194aea1ddb803ac621c0ae84a)

- see https://docs.python.org/3/using/windows.html#utf-8-mode

- Added explicit environment variable declarations. [80fe7ef](https://github.com/callowayproject/bump-my-version/commit/80fe7ef0cf1005333143cce38835dbc9ad811884)

- Added a github CI workflow. [2b3b358](https://github.com/callowayproject/bump-my-version/commit/2b3b3585afe3fdcf13ff47a229b4e3d3b5dacdc9)
Expand All @@ -816,6 +838,7 @@

- __main__.py
- aliases.py

- Added LICENSE. [34a9be5](https://github.com/callowayproject/bump-my-version/commit/34a9be5617a24b9d7eb042dc12e657ef1eb4258c)

- Added tests for version parsing errors. [71a204b](https://github.com/callowayproject/bump-my-version/commit/71a204b0eb1ea2e7ae291055f26f5c499d429f1b)
Expand Down
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
> - Add better configuration validation using [Pydantic](https://docs.pydantic.dev)
> - Make the code and tests easier to read and maintain

<!--start-->

## Overview

Expand All @@ -31,12 +32,6 @@ Bump My Version's purpose is to:
- Tagging releases
- Reading version numbers from tags


## Future Direction

- Switch having both the version part and files to change as arguments on the command line.
- Allow for multiple tags, including one that moves for having a `v2` that always points to the latest version of version 2. [For example](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations)

## Installation

You can download and install the latest version of this software from the Python package index (PyPI) as follows:
Expand All @@ -51,10 +46,6 @@ Please find the changelog here: [CHANGELOG.md](CHANGELOG.md)

## Usage for version incrementing

> **NOTE:**
>
> Throughout this document, you can use `bumpversion` or `bump-my-version` interchangeably.

There are two modes of operation: On the command line for single-file operation and using a configuration file (`pyproject.toml` or `.bumpversion.toml`) for more complex multi-file operations.

> **WARNING:**
Expand Down Expand Up @@ -130,9 +121,9 @@ Example output:
`-h, --help`
Print help and exit

## Using bump-my-version in a script
## Using Bump My Version in a script

If you need to use the version generated by bump-my-version in a script, you can make use of the `show` subcommand.
If you need to use the version generated by Bump My Version in a script, you can make use of the `show` subcommand.

Say, for example, that you are using git-flow to manage your project and want to automatically create a release. When you issue `git flow release start` you need to know the new version before applying the change.

Expand Down Expand Up @@ -160,4 +151,6 @@ workflow, as it is intended to be very versatile.

## License

bump-my-version is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
Bump My Version is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

<!--end-->
19 changes: 18 additions & 1 deletion bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def cli(ctx: Context) -> None:
"--search",
"--replace",
"--no-configured-files",
"--ignore-missing-files",
"--ignore-missing-version",
],
},
Expand Down Expand Up @@ -160,6 +161,12 @@ def cli(ctx: Context) -> None:
"ignoring the files from the configuration file."
),
)
@click.option(
"--ignore-missing-files",
is_flag=True,
envvar="BUMPVERSION_IGNORE_MISSING_FILES",
help="Ignore any missing files when searching and replacing in files.",
)
@click.option(
"--ignore-missing-version",
is_flag=True,
Expand Down Expand Up @@ -240,6 +247,7 @@ def bump(
replace: Optional[str],
regex: Optional[bool],
no_configured_files: bool,
ignore_missing_files: bool,
ignore_missing_version: bool,
dry_run: bool,
commit: Optional[bool],
Expand All @@ -256,7 +264,7 @@ def bump(

ARGS may contain any of the following:

VERSION_PART is the part of the version to increase, e.g. `minor` .
VERSION_PART is the part of the version to increase, e.g. `minor`.
Valid values include those given in the `--serialize` / `--parse` option.

FILES are additional file(s) to modify.
Expand All @@ -281,6 +289,7 @@ def bump(
tag_message=tag_message,
message=message,
commit_args=commit_args,
ignore_missing_files=ignore_missing_files,
ignore_missing_version=ignore_missing_version,
regex=regex,
)
Expand Down Expand Up @@ -444,6 +453,12 @@ def show(args: List[str], config_file: Optional[str], format_: str, increment: O
envvar="BUMPVERSION_IGNORE_MISSING_VERSION",
help="Ignore any Version Not Found errors when searching and replacing in files.",
)
@click.option(
"--ignore-missing-files",
is_flag=True,
envvar="BUMPVERSION_IGNORE_MISSING_FILES",
help="Ignore any missing files when searching and replacing in files.",
)
@click.option(
"--dry-run",
"-n",
Expand All @@ -465,6 +480,7 @@ def replace(
regex: bool,
no_configured_files: bool,
ignore_missing_version: bool,
ignore_missing_files: bool,
dry_run: bool,
) -> None:
"""
Expand Down Expand Up @@ -492,6 +508,7 @@ def replace(
message=None,
commit_args=None,
ignore_missing_version=ignore_missing_version,
ignore_missing_files=ignore_missing_files,
regex=regex,
)

Expand Down
1 change: 1 addition & 0 deletions bumpversion/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"replace": "{new_version}",
"regex": False,
"ignore_missing_version": False,
"ignore_missing_files": False,
"tag": False,
"sign_tags": False,
"tag_name": "v{new_version}",
Expand Down
1 change: 1 addition & 0 deletions bumpversion/config/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def update_config_file(
replace=config.replace,
regex=config.regex,
ignore_missing_version=True,
ignore_missing_file=True,
serialize=config.serialize,
parse=config.parse,
)
Expand Down
3 changes: 3 additions & 0 deletions bumpversion/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class FileChange(BaseModel):
replace: str
regex: bool
ignore_missing_version: bool
ignore_missing_file: bool
filename: Optional[str] = None
glob: Optional[str] = None # Conflicts with filename. If both are specified, glob wins
key_path: Optional[str] = None # If specified, and has an appropriate extension, will be treated as a data file
Expand Down Expand Up @@ -84,6 +85,7 @@ class Config(BaseSettings):
replace: str
regex: bool
ignore_missing_version: bool
ignore_missing_files: bool
tag: bool
sign_tags: bool
tag_name: str
Expand Down Expand Up @@ -116,6 +118,7 @@ def add_files(self, filename: Union[str, List[str]]) -> None:
replace=self.replace,
regex=self.regex,
ignore_missing_version=self.ignore_missing_version,
ignore_missing_file=self.ignore_missing_files,
)
)
self.files = list(files)
Expand Down
1 change: 1 addition & 0 deletions bumpversion/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def get_all_file_configs(config_dict: dict) -> List[FileChange]:
"search": config_dict["search"],
"replace": config_dict["replace"],
"ignore_missing_version": config_dict["ignore_missing_version"],
"ignore_missing_file": config_dict["ignore_missing_files"],
"regex": config_dict["regex"],
}
files = [{k: v for k, v in filecfg.items() if v is not None} for filecfg in config_dict["files"]]
Expand Down
Loading
Loading