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
refactor: separate update generation #9788
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4ebf083
refactor: separate update generation
rarkins 46895e7
Merge branch 'main' into refactor/generate-update
rarkins 68195f2
update snapshot
rarkins 94a9037
Apply suggestions from code review
rarkins 649dd19
revert
rarkins 3218ac9
Merge branch 'main' into refactor/generate-update
rarkins File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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,68 @@ | ||
import type { Release } from '../../../../datasource'; | ||
import { logger } from '../../../../logger'; | ||
import type { LookupUpdate } from '../../../../manager/types'; | ||
import type { VersioningApi } from '../../../../versioning'; | ||
import type { LookupUpdateConfig } from './types'; | ||
import { getUpdateType } from './update-type'; | ||
|
||
export function generateUpdate( | ||
config: LookupUpdateConfig, | ||
versioning: VersioningApi, | ||
currentVersion: string, | ||
bucket: string, | ||
release: Release | ||
): LookupUpdate { | ||
const newVersion = release.version; | ||
const update: LookupUpdate = { | ||
bucket, | ||
newVersion, | ||
newValue: null, | ||
}; | ||
const releaseFields = [ | ||
'checksumUrl', | ||
'downloadUrl', | ||
'newDigest', | ||
'releaseTimestamp', | ||
]; | ||
for (const field of releaseFields) { | ||
if (release[field] !== undefined) { | ||
update[field] = release[field]; | ||
} | ||
} | ||
const { currentValue, rangeStrategy } = config; | ||
try { | ||
update.newValue = versioning.getNewValue({ | ||
currentValue, | ||
rangeStrategy, | ||
currentVersion, | ||
newVersion, | ||
}); | ||
} catch (err) /* istanbul ignore next */ { | ||
logger.warn( | ||
{ err, currentValue, rangeStrategy, currentVersion, newVersion }, | ||
'getNewValue error' | ||
); | ||
update.newValue = currentValue; | ||
rarkins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
update.newMajor = versioning.getMajor(newVersion); | ||
update.newMinor = versioning.getMinor(newVersion); | ||
update.updateType = | ||
update.updateType || | ||
getUpdateType(config, versioning, currentVersion, newVersion); | ||
if (!versioning.isVersion(update.newValue)) { | ||
update.isRange = true; | ||
} | ||
if (rangeStrategy === 'update-lockfile' && currentValue === update.newValue) { | ||
update.isLockfileUpdate = true; | ||
} | ||
if ( | ||
rangeStrategy === 'bump' && | ||
versioning.matches(newVersion, currentValue) | ||
) { | ||
update.isBump = true; | ||
} | ||
if (versioning.valueToVersion) { | ||
update.newVersion = versioning.valueToVersion(update.newVersion); | ||
} | ||
return update; | ||
} |
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
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.
Need to check this isn't a mistake
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.
It's because you moved the
versioning.valueToVersion
call to inside theisValid
condition and git submodules don't have a current value.renovate/lib/workers/repository/process/lookup/index.ts
Line 57 in 9a30604
@JamieMagee Maybe we should pass the tracking branch as current value and add a git versioning, which allows branches / tags as version?
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.
So we call
valueToVersion
now only on validcurrentValue
. Maybe we should mark this pr as feature, as it causes a bahavior change here.