-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: refactor Version.bump()
to accept bumping major/minor/patch/last
#452
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6bdf0f2
Add new `VersionBumpType` and refactor `Version.bump()` to determine …
hadim 6748325
remove left over default for bump type
hadim 4d37df4
Return an error instead of panic
hadim 93036bc
use thiserror for VersionBumpError
hadim 2228f1c
wip attempt for the python binding
hadim f4ea4c6
Python binding wrap up
hadim fd7f90a
Merge branch 'main' into bump
hadim 9283770
introduce `VersionBumpType::Segment(i32)`
hadim 4ac1858
python binding for `bump_segment`
hadim 90cd9ce
lint
hadim 951fbc8
cleaning
hadim 87bd09b
more cleaning
hadim 2c09d87
Merge branch 'main' into bump
hadim 3c85dba
Update py-rattler/src/version/mod.rs
hadim d3a6362
Refactor version bumping methods in PyVersion
hadim 4d77802
Remove unused test_bump function
hadim 1f02dff
Merge branch 'main' into bump
hadim a471b0c
move tests to doctests
hadim 5f6e070
cleaning
hadim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use thiserror::Error; | ||
|
||
/// VersionBumpType is used to specify the type of bump to perform on a version. | ||
#[derive(Clone)] | ||
pub enum VersionBumpType { | ||
/// Bump the major version number. | ||
Major, | ||
/// Bump the minor version number. | ||
Minor, | ||
/// Bump the patch version number. | ||
Patch, | ||
/// Bump the last version number. | ||
Last, | ||
/// Bump a given segment. If negative, count from the end. | ||
Segment(i32), | ||
} | ||
|
||
/// VersionBumpError is used to specify the type of error that occurred when bumping a version. | ||
#[derive(Error, Debug, PartialEq)] | ||
pub enum VersionBumpError { | ||
/// Cannot bump the major segment of a version with less than 1 segment. | ||
#[error("cannot bump the major segment of a version with less than 1 segment")] | ||
NoMajorSegment, | ||
/// Cannot bump the minor segment of a version with less than 2 segments. | ||
#[error("cannot bump the minor segment of a version with less than 2 segments")] | ||
NoMinorSegment, | ||
/// Cannot bump the patch segment of a version with less than 3 segments. | ||
#[error("cannot bump the patch segment of a version with less than 3 segments")] | ||
NoPatchSegment, | ||
/// Cannot bump the last segment of a version with no segments. | ||
#[error("cannot bump the last segment of a version with no segments")] | ||
NoLastSegment, | ||
/// Invalid segment index. | ||
#[error("cannot bump the segment '{index:?}' of a version if it's not present")] | ||
InvalidSegment { | ||
/// The segment index that was attempted to be bumped. | ||
index: i32, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a
Segment(uint)
type? So that we can explicitly select the segment to bump?We might also consider that bumping non-existent segments should be possible. Usually, all non-existent segments are implicit
.0
, so bumping thepatch
of a1.0
could also result in1.0.1
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you prefer to instead fail, so it also builds incentive for the user to explicitly use
x.x.x
instead ofx
orx.x
?Unless you feel strongly here, I would prefer to let it for another PR (I can open a ticket if you want).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added support for
VersionBumpType::Segment(i32)
in 9283770 (rust side only).