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 --bump for version command #298

Merged
merged 6 commits into from
Jun 6, 2023
Merged

Conversation

ischaojie
Copy link
Contributor

#285

➜  o git:(main) ✗ rye version
0.1.0
➜  o git:(main) ✗ rye version 0.2.0
version set to 0.2.0
➜  o git:(main) ✗ rye version --bump major
version bumped to 1.2.0
➜  o git:(main) ✗ rye version --bump minor
version bumped to 1.3.0
➜  o git:(main) ✗ rye version --bump patch
version bumped to 1.3.1
➜  o git:(main) ✗ rye version --bump ooo

@mitsuhiko
Copy link
Collaborator

This makes sense, but I think it needs some reasonable story to talk about post and dev versions. Currently if you are on 1.0.0.dev0 and you bump minor you end up at 1.0.1.dev0. I propose the following logic:

  • if you do a any bump and there is a dev version, remove dev: 1.0.0.dev0 -> 1.0.0 and emit a warning
  • if there is a post marker on the release, remove it and bump: 1.0.0.post1 -> 1.1.0 for minor for instance

@ischaojie
Copy link
Contributor Author

➜  o git:(main) ✗ rye version
0.1.0.dev1
➜  o git:(main) ✗ rye version --bump major
warning: dev version will be bumped to release version
version bumped to 0.1.0
➜  o git:(main) ✗ rye version             
0.1.0.post2
➜  o git:(main) ✗ rye version --bump minor
version bumped to 0.2.0

"major" => version.release[0] += 1,
"minor" => version.release[1] += 1,
"patch" => version.release[2] += 1,
_ => return,
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to give an error here on invalid input. Right now i think you could use an enum and then clap would handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, enum is indeed in my consideration.

style("warning:").red()
);
} else {
version.release[bump as usize] += 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just realized that you can have a version 1.0 which results in release being [1, 0]. This would on a minor bump cause a panic here. I think it would need to initialize missing values to 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

➜  o git:(main) ✗ rye version
1
➜  o git:(main) ✗ rye version --bump minor
version bumped to 1.1
➜  o git:(main) ✗ rye version --bump patch
version bumped to 1.1.1
➜  o git:(main) ✗ rye version 1.0
version set to 1.0
➜  o git:(main) ✗ rye version --bump minor
version bumped to 1.1
➜  o git:(main) ✗ rye version --bump patch
version bumped to 1.1.1

@mitsuhiko mitsuhiko merged commit 3bc1dc4 into astral-sh:main Jun 6, 2023
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.

3 participants