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

fix(gradle): Avoid crash for missing managerData #11727

Merged
merged 10 commits into from Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 23 additions & 14 deletions lib/manager/gradle/shallow/extract.ts
@@ -1,9 +1,11 @@
import { DeploymentStatus } from 'azure-devops-node-api/interfaces/ReleaseInterfaces';
import * as upath from 'upath';
import {
id as datasource,
defaultRegistryUrls,
} from '../../../datasource/maven';
import { logger } from '../../../logger';
import { SkipReason } from '../../../types';
import { readLocalFile } from '../../../util/fs';
import type {
ExtractConfig,
Expand Down Expand Up @@ -98,20 +100,27 @@ export async function extractAllPackageFiles(
}

elevateFileReplacePositionField(extractedDeps).forEach((dep) => {
const key = dep.managerData.packageFile;
const pkgFile: PackageFile = packageFilesByName[key];
const { deps } = pkgFile;
deps.push({
...dep,
registryUrls: [
...new Set([
...defaultRegistryUrls,
...(dep.registryUrls || []),
...registryUrls,
]),
],
});
packageFilesByName[key] = pkgFile;
const key = dep.managerData?.packageFile;
if (key) {
const pkgFile: PackageFile = packageFilesByName[key];
const { deps } = pkgFile;
deps.push({
...dep,
registryUrls: [
...new Set([
...defaultRegistryUrls,
...(dep.registryUrls || []),
...registryUrls,
]),
],
});
packageFilesByName[key] = pkgFile;
} /* istanbul ignore next */ else {
rarkins marked this conversation as resolved.
Show resolved Hide resolved
logger.warn(
{ dep },
`Failed to process Gradle dependency: ${dep.lookupName}`
zharinov marked this conversation as resolved.
Show resolved Hide resolved
);
}
});

return Object.values(packageFilesByName);
Expand Down
1 change: 1 addition & 0 deletions lib/manager/gradle/shallow/parser.ts
Expand Up @@ -24,6 +24,7 @@ import {
isDependencyString,
parseDependencyString,
} from './utils';
import { SkipReason } from '../../../types';

function matchTokens(
tokens: Token[],
Expand Down