From 5a511732c0781f1e9fc2b07c2f69b001d7d62d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20K=C3=B6rner?= <20133276+dazze1812@users.noreply.github.com> Date: Mon, 15 Jan 2024 09:43:48 +0100 Subject: [PATCH] fix(manager/conan): allow ref with user only (#26516) Co-authored-by: Michael Kriese <michael.kriese@visualon.de> --- lib/modules/manager/conan/__fixtures__/conanfile.py | 2 +- lib/modules/manager/conan/extract.spec.ts | 7 +++++++ lib/modules/manager/conan/extract.ts | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/modules/manager/conan/__fixtures__/conanfile.py b/lib/modules/manager/conan/__fixtures__/conanfile.py index 6f5a7ecadf..3303b80083 100644 --- a/lib/modules/manager/conan/__fixtures__/conanfile.py +++ b/lib/modules/manager/conan/__fixtures__/conanfile.py @@ -3,7 +3,7 @@ from conans import ConanFile class Pkg(ConanFile): python_requires = "pyreq/0.1@user/channel" # recipe to reuse code from build_requires = "tool_a/0.2@user/testing", "tool_b/0.2@user/testing" - requires = "req_a/1.0", "req_l/2.1@otheruser/testing" + requires = "req_a/1.0", "req_l/2.1@otheruser/testing", "req_x/6.1@useronly" requires = [("req_b/0.1@user/testing"), ("req_d/0.2@dummy/stable", "override"), diff --git a/lib/modules/manager/conan/extract.spec.ts b/lib/modules/manager/conan/extract.spec.ts index 8513b874ea..632686835a 100644 --- a/lib/modules/manager/conan/extract.spec.ts +++ b/lib/modules/manager/conan/extract.spec.ts @@ -152,6 +152,13 @@ describe('modules/manager/conan/extract', () => { packageName: 'req_l/2.1@otheruser/testing', replaceString: 'req_l/2.1@otheruser/testing', }, + { + currentValue: '6.1', + depName: 'req_x', + depType: 'requires', + packageName: 'req_x/6.1@useronly/_', + replaceString: 'req_x/6.1@useronly', + }, { currentValue: '0.1', depName: 'req_b', diff --git a/lib/modules/manager/conan/extract.ts b/lib/modules/manager/conan/extract.ts index 98143b9b28..e35e16a2eb 100644 --- a/lib/modules/manager/conan/extract.ts +++ b/lib/modules/manager/conan/extract.ts @@ -4,7 +4,7 @@ import type { PackageDependency, PackageFileContent } from '../types'; import { isComment } from './common'; const regex = regEx( - `(?<name>[-_a-z0-9]+)/(?<version>[^@\n{*"']+)(?<userChannel>@[-_a-zA-Z0-9]+/[^#\n.{*"' ]+)?#?(?<revision>[-_a-f0-9]+[^\n{*"'])?`, + `(?<name>[-_a-z0-9]+)/(?<version>[^@\n{*"']+)(?<userChannel>@[-_a-zA-Z0-9]+(?:/[^#\n.{*"' ]+|))?#?(?<revision>[-_a-f0-9]+[^\n{*"'])?`, ); function setDepType(content: string, originalType: string): string { @@ -52,6 +52,9 @@ export function extractPackageFile(content: string): PackageFileContent | null { if (matches.groups.userChannel) { userAndChannel = matches.groups.userChannel; replaceString = `${depName}/${currentValue}${userAndChannel}`; + if (!userAndChannel.includes('/')) { + userAndChannel = `${userAndChannel}/_`; + } } const packageName = `${depName}/${currentValue}${userAndChannel}`; -- GitLab