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

refactor(process/libyear): early return if no releaseTimestamp for current version #33967

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/workers/repository/process/libyear.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ describe('workers/repository/process/libyear', () => {
};
calculateLibYears(packageFiles);
expect(logger.logger.debug).toHaveBeenCalledWith(
'No releaseTimestamp for some/image update to 2.0.0',
'No currentVersionTimestamp for some/image',
);
expect(logger.logger.debug).toHaveBeenCalledWith(
'No releaseTimestamp for dep1 update to 3.0.0',
);
expect(logger.logger.debug).toHaveBeenCalledWith(
'No currentVersionTimestamp for dep3',
);
expect(logger.logger.debug).toHaveBeenCalledWith(
{
managerLibYears: {
Expand Down
17 changes: 9 additions & 8 deletions lib/workers/repository/process/libyear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ export function calculateLibYears(
for (const file of files) {
let fileLibYears = 0;
for (const dep of file.deps) {
if (!dep.currentVersionTimestamp) {
logger.debug(`No currentVersionTimestamp for ${dep.depName}`);
continue;
}
// timestamps are in ISO format
const currentVersionDate = DateTime.fromISO(
dep.currentVersionTimestamp,
);

if (dep.updates?.length) {
for (const update of dep.updates) {
if (!update.releaseTimestamp) {
Expand All @@ -21,14 +30,6 @@ export function calculateLibYears(
);
continue;
}
if (!dep.currentVersionTimestamp) {
logger.debug(`No currentVersionTimestamp for ${dep.depName}`);
continue;
}
// timestamps are in ISO format
const currentVersionDate = DateTime.fromISO(
dep.currentVersionTimestamp,
);
const releaseDate = DateTime.fromISO(update.releaseTimestamp);
const libYears = releaseDate.diff(
currentVersionDate,
Expand Down