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(package): added showing gradle version based on the gradle.properties file #4432
Conversation
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Please fix any clippy issues. I would also prefer if both files are considered in case the first doesn't have the version, but the other one does. context.read_file_from_pwd("build.gradle")
.and_then(|contents| {
// ...
}).or_else(|| {
// try other file
}) |
Isn't the program already doing that? If the gradle.properties file returns none, it'll look in the other file. It looks like clippy is yelling at me for my bad code. I wish I had found out about this earlier. Clippy is nice. |
It may exist, but not contain the version |
OOh. Sorry, I also don't really understand how the gradle build system works. Never used it. Thanks. |
I don't know how it works in detail either, just being prudent. |
Do you have any idea which file I should prefer? I guess it doesn't really matter since the version shouldn't exist twice. |
I would go with |
Alright it looks clean now. |
The project version is either stored in the build script directly or externalized to
To my understanding it wouldn't make sense to have a version literal in the build script and in the properties file as this would mean you'd have to maintain it in two places. So I would look if there's a version to be found in By the way, thanks a lot for tackling this @BattleCh1cken! |
No problem! Thanks for being a maintainer! |
I'm not. I just felt like giving my 2 cents as I had opened the issue requesting this little enhancement. |
Welp. Thanks for helping me regardless. |
src/modules/package.rs
Outdated
let properties_file_contents = context.read_file_from_pwd("gradle.properties")?; | ||
let re = Regex::new(r"version=(?P<version>.*)").unwrap(); | ||
let caps = re.captures(&properties_file_contents)?; | ||
format_version(&caps["version"], config.version_format) |
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.
Given the comments from moritzreiter, please read the properties file first.
Thank you for your contribution @BattleCh1cken and thank you for reviewing @moritzreiter and @davidkna. |
…rties file (starship#4432) * feat: added showing gradle version based on the gradle.properties file * fix: wouldn't return version * fix: forgot to remove "version=" from returned version" * fix: ran rustfmt * fix: test now actually tests for something Co-authored-by: David Knaack <davidkna@users.noreply.github.com> * fix: the regex actually makes sense now * fix: complete refactor of control flow * Delete flake.nix * changed order in which files are processed Co-authored-by: BattleCh1cken <BattleCh1cken@Larkov.de> Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Supplies an additional way to get gradle version.
Description
I added a condition in the get_gradle_version that checks if the version in build.gradle doesn't exist, and then gets the version from gradle.properties instead.
I'm fairly certain that the way I implemented this is very janky, but I don't know how to fix it.
Motivation and Context
Closes #4410
Screenshots (if appropriate):
How Has This Been Tested?
I ran cargo test.
I created a new test that replicated a working directory with a gradle.properties file.
Checklist: