Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(manager/conan): allow ref with user only #26516

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/modules/manager/conan/__fixtures__/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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"),
Expand All @@ -12,6 +12,7 @@ class Pkg(ConanFile):
requires = (("req_c/1.0@user/stable", "private"), )
requires = ("req_f/1.0@user/stable", ("req_h/3.0@other/beta", "override"))
requires = "req_g/[>1.0 <1.8]@user/stable"
requires = "req_z/[>1.0 <1.8, include_prerelease]@user/stable"
# requires = "commentedout/[>1.0 <1.8]@user/stable"
# requires = "commentedout2/[>1.0 <1.8]@user/stable"
requires = (("req_l/1.0@user/stable#bc592346b33fd19c1fbffce25d1e4236", "private"), )
Expand Down
14 changes: 14 additions & 0 deletions lib/modules/manager/conan/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -201,6 +208,13 @@ describe('modules/manager/conan/extract', () => {
packageName: 'req_g/[>1.0 <1.8]@user/stable',
replaceString: 'req_g/[>1.0 <1.8]@user/stable',
},
{
currentValue: '[>1.0 <1.8, include_prerelease]',
depName: 'req_z',
depType: 'requires',
packageName: 'req_z/[>1.0 <1.8, include_prerelease]@user/stable',
replaceString: 'req_z/[>1.0 <1.8, include_prerelease]@user/stable',
},
{
autoReplaceStringTemplate:
'{{depName}}/{{newValue}}@user/stable{{#if newDigest}}#{{newDigest}}{{/if}}',
Expand Down
5 changes: 4 additions & 1 deletion lib/modules/manager/conan/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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}`;

Expand Down
9 changes: 7 additions & 2 deletions lib/modules/versioning/conan/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ export function makeVersion(
export function cleanVersion(version: string): string {
if (version) {
return version
.replace(regEx(/,|\[|\]|"|include_prerelease=|loose=|True|False/g), '')
.replace(
regEx(
/,|\[|\]|"|include_prerelease=|include_prerelease|loose=|True|False/g,
),
'',
)
.trim();
}
return version;
Expand All @@ -44,7 +49,7 @@ export function getOptions(input: string): {
let loose = true;
if (input) {
includePrerelease =
input.includes('include_prerelease=True') &&
input.includes('include_prerelease') &&
!input.includes('include_prerelease=False');
loose = input.includes('loose=True') || !input.includes('loose=False');
}
Expand Down