Skip to content
Snippets Groups Projects
Unverified Commit 27a35137 authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

fix(git-submodules): don’t include token in lookupName (#9556)

parent 7d4e7df8
No related branches found
No related tags found
No related merge requests found
import { mock } from 'jest-mock-extended'; import { mock } from 'jest-mock-extended';
import _simpleGit, { Response, SimpleGit } from 'simple-git'; import _simpleGit, { Response, SimpleGit } from 'simple-git';
import { getName, partial } from '../../../test/util'; import { getName, partial } from '../../../test/util';
import * as hostRules from '../../util/host-rules';
import type { PackageFile } from '../types'; import type { PackageFile } from '../types';
import extractPackageFile from './extract'; import extractPackageFile from './extract';
...@@ -44,6 +45,7 @@ describe(getName(__filename), () => { ...@@ -44,6 +45,7 @@ describe(getName(__filename), () => {
}); });
describe('extractPackageFile()', () => { describe('extractPackageFile()', () => {
it('extracts submodules', async () => { it('extracts submodules', async () => {
hostRules.add({ hostName: 'github.com', token: 'abc123' });
let res: PackageFile; let res: PackageFile;
expect( expect(
await extractPackageFile('', '.gitmodules.1', { localDir }) await extractPackageFile('', '.gitmodules.1', { localDir })
......
...@@ -114,7 +114,13 @@ export default async function extractPackageFile( ...@@ -114,7 +114,13 @@ export default async function extractPackageFile(
// Find HTTP URL, then apply token // Find HTTP URL, then apply token
let httpSubModuleUrl = getHttpUrl(subModuleUrl); let httpSubModuleUrl = getHttpUrl(subModuleUrl);
const hostRule = hostRules.find({ url: httpSubModuleUrl }); const hostRule = hostRules.find({ url: httpSubModuleUrl });
httpSubModuleUrl = getHttpUrl(subModuleUrl, hostRule?.token); if (hostRule?.token) {
logger.debug(
{ httpSubModuleUrl },
'Found hostRules token for submodule'
);
httpSubModuleUrl = getHttpUrl(subModuleUrl, hostRule.token);
}
const currentValue = await getBranch( const currentValue = await getBranch(
gitModulesPath, gitModulesPath,
name, name,
...@@ -122,7 +128,7 @@ export default async function extractPackageFile( ...@@ -122,7 +128,7 @@ export default async function extractPackageFile(
); );
return { return {
depName: path, depName: path,
lookupName: httpSubModuleUrl, lookupName: getHttpUrl(subModuleUrl),
currentValue, currentValue,
currentDigest, currentDigest,
}; };
......
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