Skip to content
Snippets Groups Projects
Commit 65839b78 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix(git-submodules): add try-catch around extract phase

parent 989caae2
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ import Git from 'simple-git/promise';
import upath from 'upath';
import * as datasourceGitSubmodules from '../../datasource/git-submodules';
import { logger } from '../../logger';
import { ManagerConfig, PackageFile } from '../common';
type GitModule = {
......@@ -52,26 +53,28 @@ async function getModules(
git: Git.SimpleGit,
gitModulesPath: string
): Promise<GitModule[]> {
const modules = (
(await git.raw([
'config',
'--file',
gitModulesPath,
'--get-regexp',
'path',
])) ?? /* istanbul ignore next: should never happen */ ''
)
.trim()
.split(/\n/)
.filter((s) => !!s);
const res: GitModule[] = [];
try {
const modules = (
(await git.raw([
'config',
'--file',
gitModulesPath,
'--get-regexp',
'path',
])) ?? /* istanbul ignore next: should never happen */ ''
)
.trim()
.split(/\n/)
.filter((s) => !!s);
for (const line of modules) {
const [, name, path] = line.split(/submodule\.(.+?)\.path\s(.+)/);
res.push({ name, path });
for (const line of modules) {
const [, name, path] = line.split(/submodule\.(.+?)\.path\s(.+)/);
res.push({ name, path });
}
} catch (err) /* istanbul ignore next */ {
logger.warn({ err }, 'Error getting git submodules during extract');
}
return res;
}
......@@ -89,21 +92,31 @@ export default async function extractPackageFile(
return null;
}
const deps = await Promise.all(
depNames.map(async ({ name, path }) => {
const [currentValue] = (await git.subModule(['status', path]))
.trim()
.split(/[+\s]/);
const submoduleBranch = await getBranch(gitModulesPath, name);
const subModuleUrl = await getUrl(git, gitModulesPath, name);
return {
depName: path,
registryUrls: [subModuleUrl, submoduleBranch],
currentValue,
currentDigest: currentValue,
};
})
);
const deps = (
await Promise.all(
depNames.map(async ({ name, path }) => {
try {
const [currentValue] = (await git.subModule(['status', path]))
.trim()
.split(/[+\s]/);
const submoduleBranch = await getBranch(gitModulesPath, name);
const subModuleUrl = await getUrl(git, gitModulesPath, name);
return {
depName: path,
registryUrls: [subModuleUrl, submoduleBranch],
currentValue,
currentDigest: currentValue,
};
} catch (err) /* istanbul ignore next */ {
logger.warn(
{ err },
'Error mapping git submodules during extraction'
);
return null;
}
})
)
).filter(Boolean);
return { deps, datasource: datasourceGitSubmodules.id };
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment