-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Gradle bump strategy #33453
base: main
Are you sure you want to change the base?
Gradle bump strategy #33453
Conversation
|
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.
Thanks for the contribution. Looks promising but can benefit from some refinement:
- Please add a reproduction repo so that your changes can be tested against, incl a dep with regular maven based range and one with a range + strict version enforcement.
- Run
prettier
and undo changes unrelated to the bump strategy. - Keep dep extraction to the minimum, it's not the place to decide what part to bump
Most importantly: To reduce the complexity of your changes, it would be great if you could limit this PR to the already supported Maven range syntax, for now ignoring gradle's strict version notation. This should allow you to reuse the existing maven range parsing, it should work without changes to the parser and, unless I missed something, only require a few adaptations in the gradle versioning
const updatablePart = mavenStyleRange.upperBound ?? mavenStyleRange.lowerBound; | ||
return { | ||
depName: `${groupId}:${artifactId}`, | ||
currentValue: updatablePart, |
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.
currentValue
is supposed to include the version value found for the dependency that is extracted. It's not the right place to decide whether to update the lower or upper bound. I think updating the lower bound is a bit pointless overall. Such a check can be done later while comparing update candidates with the full range (and the comparison logic in the versioning).
The only thing that may need adaptation here is the addition of !
and a space to the version regex.
for (const line of input.split(newlineRegex)) { | ||
const lineMatch = propRegex.exec(line); | ||
if (lineMatch?.groups) { | ||
const { key, value, leftPart } = lineMatch.groups; | ||
// TODO: we dont need to check isDependency, the parseDependency does this by itself |
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.
That's correct but please keep your changes strictly limited to what's relevant for the functionality you'd like to add. Refactoring can be done separately.
@@ -44,6 +53,11 @@ export function isDependencyString(input: string): boolean { | |||
return false; | |||
} | |||
|
|||
const mavenStyleRange = parseMavenStyleRange(tempVersionPart); | |||
if (mavenStyleRange) { | |||
return true; |
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.
This is wrong as it bypasses all subsequent checks
@@ -44,6 +53,11 @@ export function isDependencyString(input: string): boolean { | |||
return false; | |||
} | |||
|
|||
const mavenStyleRange = parseMavenStyleRange(tempVersionPart); |
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.
I see no need for this here. Should be enough to have versionLikeSubstring
match ranges, which it already can except for those containing !
and spaces.
); | ||
|
||
const versionLikeRegex = regEx('^(?<version>[-_.\\[\\](),a-zA-Z0-9+]+)'); | ||
const versionLikeRegex = regEx('^(?<version>[-_.\\[\\](),a-zA-Z0-9+! ]*[-_.\\[\\](),a-zA-Z0-9+])'); |
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.
What's the intention here? Is it an attempt to add !
and a space to the list of allowed characters? If yes, this can be done simpler
|
||
const mavenStyleRangeRegex = regEx(/^(?<openingBracket>[[\](])(?<lowerBound>[-._+a-zA-Z0-9]+)?(?<seperator>\s*,\s*)(?<upperBound>[-._+a-zA-Z0-9]+)?(?<closingBracket>[[\])])(?:!!(?<preferredVersion>[-._+a-zA-Z0-9]+))?$/) | ||
|
||
export function parseMavenStyleRange(input: string): MavenStyleRange | null { |
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.
There already is mavenBasedRangeRegex
and parseMavenBasedRange
, which does quite the same, except that it lacks support for preferred versions. What speaks against extending the existing implementation instead of reinventing maven style range parsing as a whole?
@@ -128,30 +131,31 @@ const matches = (a: string, b: string): boolean => { | |||
return equals(x, y); | |||
} | |||
|
|||
const mavenBasedRange = parseMavenBasedRange(b); |
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.
This looks wrong to me. It seems you're trying to replace parseMavenBasedRange()
with your implementation, while it's still used e.g. in isValid()
.
const mavenBasedRange = parseMavenBasedRange(b); | ||
if (!mavenBasedRange) { | ||
const mavenStyleRange = parseMavenStyleRange(b); | ||
// we can not update an exclusive lower bound as we don't know |
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.
Do you mean (1.0,)
for example? If so, this should be reflected in a test too
|
||
const mavenStyleRange = parseMavenStyleRange(fullValue); | ||
if (mavenStyleRange) { | ||
const updatablePart = mavenStyleRange.upperBound ?? mavenStyleRange.lowerBound; |
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.
I guess ?? mavenStyleRange.lowerBound
can never hapepns since parseMavenStyleRange
returns null if not both lower and upper are provided?!
Changes
WIP!
This pr is not yet ready to merge, it does already exists for the purpose of getting feedback and input from discussions. Reviews welcome.
Todos: (for me)
Context
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via: