mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 07:20:39 +00:00
766db6fc6f
* build(deps): update dependency upath to v3 | datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | upath | 2.0.1 | 3.0.7 | * chore: fix types --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { simpleGit } from 'simple-git';
|
|
import upath from 'upath';
|
|
import { GlobalConfig } from '../../../config/global.ts';
|
|
import { logger } from '../../../logger/index.ts';
|
|
import { getChildEnv } from '../../../util/exec/utils.ts';
|
|
import { readLocalFile } from '../../../util/fs/index.ts';
|
|
import { getGitEnvironmentVariables } from '../../../util/git/auth.ts';
|
|
import type { UpdateDependencyConfig } from '../types.ts';
|
|
|
|
export default async function updateDependency({
|
|
fileContent,
|
|
upgrade,
|
|
}: UpdateDependencyConfig): Promise<string | null> {
|
|
// TODO: types (#22198)
|
|
const localDir = GlobalConfig.get('localDir')!;
|
|
const gitSubmoduleAuthEnvironmentVariables = getGitEnvironmentVariables([
|
|
'git-tags',
|
|
'git-refs',
|
|
]);
|
|
const gitEnv = getChildEnv({ env: gitSubmoduleAuthEnvironmentVariables });
|
|
const git = simpleGit(localDir).env(gitEnv);
|
|
// TODO: types (#22198)
|
|
const submoduleGit = simpleGit(upath.join(localDir, upgrade.depName!)).env(
|
|
gitEnv,
|
|
);
|
|
|
|
try {
|
|
await git.submoduleUpdate(['--checkout', '--init', upgrade.depName!]);
|
|
await submoduleGit.checkout([upgrade.newDigest!]);
|
|
if (upgrade.newValue && upgrade.currentValue !== upgrade.newValue) {
|
|
await git.subModule([
|
|
'set-branch',
|
|
'--branch',
|
|
upgrade.newValue,
|
|
upgrade.depName!,
|
|
]);
|
|
const updatedPackageContent = await readLocalFile(
|
|
upgrade.packageFile!,
|
|
'utf8',
|
|
);
|
|
return updatedPackageContent!;
|
|
}
|
|
return fileContent;
|
|
} catch (err) {
|
|
logger.debug({ err }, 'submodule checkout error');
|
|
return null;
|
|
}
|
|
}
|