Skip to content

Commit

Permalink
Log packageFileName
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrunet committed Nov 20, 2024
1 parent 9410925 commit 2320159
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/modules/manager/poetry/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ function getPoetrySources(content: string): PoetrySource[] {
return sourceArray;
}

async function getMatchingHostRule(url: string | undefined): Promise<HostRule> {
async function getMatchingHostRule(
url: string | undefined,
packageFileName: string,
): Promise<HostRule> {
const scopedMatch = find({ hostType: PypiDatasource.id, url });
const hostRule = is.nonEmptyObject(scopedMatch) ? scopedMatch : find({ url });
if (hostRule) {
Expand All @@ -126,7 +129,7 @@ async function getMatchingHostRule(url: string | undefined): Promise<HostRule> {

const parsedUrl = parseUrl(url);
if (!parsedUrl) {
logger.once.debug({ url }, 'Failed to parse URL');
logger.once.debug({ url, packageFileName }, 'Failed to parse URL');
return {};
}

Expand All @@ -138,20 +141,27 @@ async function getMatchingHostRule(url: string | undefined): Promise<HostRule> {
password: accessToken,
};
}
logger.once.debug({ url }, 'Could not get Google access token');
logger.once.debug(
{ url, packageFileName },
'Could not get Google access token',
);
}

return {};
}

async function getSourceCredentialVars(
pyprojectContent: string,
packageFileName: string,
): Promise<NodeJS.ProcessEnv> {
const poetrySources = getPoetrySources(pyprojectContent);
const envVars: NodeJS.ProcessEnv = {};

for (const source of poetrySources) {
const matchingHostRule = await getMatchingHostRule(source.url);
const matchingHostRule = await getMatchingHostRule(
source.url,
packageFileName,
);
const formattedSourceName = source.name
.replace(regEx(/(\.|-)+/g), '_')
.toUpperCase();
Expand Down Expand Up @@ -215,7 +225,10 @@ export async function updateArtifacts({
config.constraints?.poetry ??
getPoetryRequirement(newPackageFileContent, existingLockFileContent);
const extraEnv = {
...(await getSourceCredentialVars(newPackageFileContent)),
...(await getSourceCredentialVars(
newPackageFileContent,
packageFileName,
)),
...getGitEnvironmentVariables(['poetry']),
PIP_CACHE_DIR: await ensureCacheDir('pip'),
};
Expand Down

0 comments on commit 2320159

Please sign in to comment.