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

189 conditional search and replace blocks #197

Merged
merged 7 commits into from
Jun 14, 2024

Conversation

coordt
Copy link
Member

@coordt coordt commented Jun 12, 2024

Add valid_bumps and invalid_bumps to file configuration.

Updated the configuration file model to support valid_bumps and invalid_bumps configurations. This feature provides control over which version section updates can trigger file changes. Adjusted various test fixtures and cleaned up tests to match these changes. Also, some updates were made to the documentation accordingly.

Add file filtering based on valid_bumps and invalid bumps.

This commit introduces the ability to filter files based on whether the specified bump type is valid. It adds valid_bumps and invalid_bumps lists in the file configurations and adjusts the bumping process to consider these configurations. Tests have been updated to reflect the new handling of valid and invalid bumps.

coordt added 3 commits June 11, 2024 15:28
Updated the configuration file model to support valid_bumps and invalid_bumps. This feature provides control over which version section updates can trigger file changes. Adjusted various test fixtures and cleaned up tests to match these changes. Also, some updates were made to the documentation accordingly.
Several new file types have been added to .gitignore for ignoring during commits. These include '.python-version', 'requirements-dev.lock', and 'requirements.lock' files.
This commit introduces the ability to filter files based on whether the specified bump type is valid or not. It adds `valid_bumps` and `invalid_bumps` lists in the file configurations and adjusts the bumping process to consider these configurations. Tests are updated to reflect these new handling of valid and invalid bumps.
@coordt coordt linked an issue Jun 12, 2024 that may be closed by this pull request
Copy link

Version hint: minor
Current version: 0.22.0
New version (when merged): 0.23.0

Comment ID: Display the version hint-auto-generated

Copy link

github-actions bot commented Jun 12, 2024

PR Preview Action v1.4.7
🚀 Deployed preview to https://callowayproject.github.io/bump-my-version/pr-preview/pr-197/
on branch gh-pages at 2024-06-13 22:29 UTC

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.77%. Comparing base (86cfb5f) to head (2224808).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #197      +/-   ##
==========================================
+ Coverage   93.73%   93.77%   +0.03%     
==========================================
  Files          25       25              
  Lines        1549     1557       +8     
  Branches      306      309       +3     
==========================================
+ Hits         1452     1460       +8     
  Misses         70       70              
  Partials       27       27              
Flag Coverage Δ
python-3.10 93.77% <100.00%> (+0.03%) ⬆️
python-3.11 93.77% <100.00%> (+0.03%) ⬆️
python-3.8 93.74% <100.00%> (+0.03%) ⬆️
python-3.9 93.74% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

docs/reference/configuration.md Outdated Show resolved Hide resolved
@@ -722,6 +723,40 @@ If `True`, don't fail if the version string to be replaced is not found in the f

if `True`, don't fail if the configured file is missing.

### valid_bumps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's more clear to name these options include_bumps and exclude_bumps? Or (dis)allow, (de)select?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great observation. Naming things is hard. I like include/exclude

type
: list of strings

The `invalid_bumps` file configuration allows you to control when this file is changed by exclusion. When a `bump <version component>` command is issued, this file is only changed if the version component is *not in this list.* The [parse](#parse) configuration defines version components.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to explicitly state that this option can't be used together with valid_bumps. Unless you want to support regex inputs, I don't see how both options can be combined

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are always combined because the included bumps are always defined. Declaring both of them doesn't make much sense, but it works. I'll try and adjust the docs accordingly.

@@ -120,6 +122,8 @@ def add_files(self, filename: Union[str, List[str]]) -> None:
regex=self.regex,
ignore_missing_version=self.ignore_missing_version,
ignore_missing_file=self.ignore_missing_files,
valid_bumps=tuple(self.parts.keys()),
invalid_bumps=(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is invalid_bumps included as empty tuple here - is it just the DEFAULT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default for invalid_bumps is None. But after consideration, I will add a default_factory to that field.

@@ -22,6 +22,8 @@ def get_all_file_configs(config_dict: dict) -> List[FileChange]:
"ignore_missing_version": config_dict["ignore_missing_version"],
"ignore_missing_file": config_dict["ignore_missing_files"],
"regex": config_dict["regex"],
"valid_bumps": tuple(config_dict["parts"]),
"invalid_bumps": (),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, same here, is invalid_bumps implemented? :-)

tests/test_config/test_files.py Show resolved Hide resolved
coordt and others added 2 commits June 13, 2024 08:26
…umps

The configuration parameters `valid_bumps` and `invalid_bumps` were renamed to `include_bumps` and `exclude_bumps` respectively. This new naming better denotes their function, and the changes were consistently applied across all related files and tests. Numerous fixture outputs were also updated to reflect these changes.
@coordt coordt requested a review from wkoot June 13, 2024 14:09

The default value, or an empty list, includes all version components.
The default value, or an empty list, includes all version components.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default value, or an empty list, includes all version components.
The default value, or an empty list, includes all version components.


type
: list of strings

The `valid_bumps` file configuration allows you to control when this file is changed. When a `bump <version component>` command is issued, this file is changed only if the version component is in this list and not in [`invalid_bumps`](#invalid_bumps). The [parse](#parse) configuration defines version components.
The `include_bumps` file configuration allows you to control when this file is changed by inclusion. Its alternative is the `exclude_bumps` configuration. When a `bump <version component>` command is issued, this file is changed only if the version component is in this list and not in [`exclude_bumps`](#exclude_bumps). The [parse](#parse) configuration defines version components.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean "inverse" instead of "alternative" ?

@Zeitsperre
Copy link

This appears to be working on my end! Thanks so much!

The changes made update the wording in the documentation to clarify the roles of `include_bumps` and `exclude_bumps` in the bump-my-version configuration. Additionally, unnecessary repetition was removed and overlapping examples were also corrected.
@coordt coordt merged commit 6374aa7 into master Jun 14, 2024
14 checks passed
@coordt coordt deleted the 189-conditional-search-and-replace-blocks branch June 14, 2024 12:03
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.

Feature: conditional search and replace blocks
3 participants