From 0803b46d23710c11c7f07bdedb3d6f4a4b3594f4 Mon Sep 17 00:00:00 2001 From: Philipp Jaschke <77045520+PJ-Schulz@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:59:43 +0200 Subject: [PATCH] fix(manager/copier): process update templates outside repository root (#30708) --- lib/modules/manager/copier/artifacts.spec.ts | 23 ++++++++++++++++++++ lib/modules/manager/copier/artifacts.ts | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/modules/manager/copier/artifacts.spec.ts b/lib/modules/manager/copier/artifacts.spec.ts index 4c2c9dc83d..9b892e5ee8 100644 --- a/lib/modules/manager/copier/artifacts.spec.ts +++ b/lib/modules/manager/copier/artifacts.spec.ts @@ -118,6 +118,29 @@ describe('modules/manager/copier/artifacts', () => { expect(execSnapshots).toMatchObject([ { cmd: 'copier update --skip-answered --defaults --answers-file .copier-answers.yml --vcs-ref 1.1.0', + options: { + cwd: '/tmp/github/some/repo', + }, + }, + ]); + }); + + it('invokes copier update with nested destination and answer file', async () => { + const execSnapshots = mockExecAll(); + + await updateArtifacts({ + packageFileName: 'apps/my-app/.copier-answers.yml', + updatedDeps: upgrades, + newPackageFileContent: '', + config: {}, + }); + + expect(execSnapshots).toMatchObject([ + { + cmd: 'copier update --skip-answered --defaults --answers-file .copier-answers.yml --vcs-ref 1.1.0', + options: { + cwd: '/tmp/github/some/repo/apps/my-app', + }, }, ]); }); diff --git a/lib/modules/manager/copier/artifacts.ts b/lib/modules/manager/copier/artifacts.ts index 1b6aa236cf..a89b6ae7bc 100644 --- a/lib/modules/manager/copier/artifacts.ts +++ b/lib/modules/manager/copier/artifacts.ts @@ -1,4 +1,5 @@ import { quote } from 'shlex'; +import upath from 'upath'; import { GlobalConfig } from '../../../config/global'; import { logger } from '../../../logger'; import { exec } from '../../../util/exec'; @@ -28,7 +29,7 @@ function buildCommand( } command.push( '--answers-file', - quote(packageFileName), + quote(upath.basename(packageFileName)), '--vcs-ref', quote(newVersion), ); @@ -72,6 +73,7 @@ export async function updateArtifacts({ const command = buildCommand(config, packageFileName, newVersion); const execOptions: ExecOptions = { + cwdFile: packageFileName, docker: {}, userConfiguredEnv: config.env, toolConstraints: [ -- GitLab