Skip to content

Commit

Permalink
Add validate-bump option to the standard version scheme (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored Oct 7, 2022
1 parent 40c25b7 commit bd2bec7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/src/hatchling/version/scheme/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def update(self, desired_version, original_version, version_data):
raise ValueError('Cannot specify multiple update operations with an explicit version')

next_version = Version(version)
if next_version <= original:
if self.config.get('validate-bump', True) and next_version <= original:
raise ValueError(
f'Version `{version}` is not higher than the original version `{original_version}`'
)
Expand Down
1 change: 1 addition & 0 deletions docs/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ This is the first stable release of Hatch v1, a complete rewrite. Enjoy!
***Added:***

- Add `env` version source to retrieve the version from an environment variable
- Add `validate-bump` option to the `standard` version scheme

***Fixed:***

Expand Down
6 changes: 4 additions & 2 deletions docs/plugins/version-scheme/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

See the documentation for [versioning](../../version.md#updating).

#### Configuration
## Configuration

The version scheme plugin name is `standard`.

Expand All @@ -24,4 +24,6 @@ The version scheme plugin name is `standard`.

## Options

There are no options available currently.
| Option | Description |
| --- | --- |
| `validate-bump` | When setting a specific version, this determines whether to check that the new version is higher than the original. The default is `true`. |
6 changes: 6 additions & 0 deletions tests/backend/version/scheme/test_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ def test_specific(isolation):
assert scheme.update('9000.0.0-rc.1', '1.0', {}) == '9000.0.0rc1'


def test_specific_not_higher_allowed(isolation):
scheme = StandardScheme(str(isolation), {'validate-bump': False})

assert scheme.update('0.24.4', '1.0.0.dev0', {}) == '0.24.4'


def test_release(isolation):
scheme = StandardScheme(str(isolation), {})

Expand Down

0 comments on commit bd2bec7

Please sign in to comment.