Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions renovate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ repository specified by `url`.
To follow a branch, use `git-refs`, set `packageName` to the full Git URL, use `exact` versioning,
and specify `branch` followed by the pinned `commit`.

For a commit-only checkout, put `"ref": "main"` last in `x-renovate` and use `url` followed by
`commit` in the source. Renovate follows that ref while Flatpak checks out the pinned commit.
Renovate uses the source URL as `packageName` by default and uses `exact` versioning. For a mirror,
use the upstream project as `depName` and the full mirror URL as `packageName`.

### GitHub release assets

Use `github-release-attachments` for an archive or file from a GitHub release. Keep the full tag
Expand Down
14 changes: 7 additions & 7 deletions renovate/flatpak.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"managerFilePatterns": ["packaging/linux/flatpak/modules/**/*.json"],
"matchStringsStrategy": "recursive",
"matchStrings": [
// Put x-renovate immediately before the URL. List datasource, depName, and the optional packageName and versioning in that order.
'"x-renovate"\\s*:\\s*\\{\\s*"datasource"\\s*:\\s*"(?<datasource>[a-z0-9_.-]+)"\\s*,\\s*"depName"\\s*:\\s*"(?<depName>[^"]+)"(?:\\s*,\\s*"packageName"\\s*:\\s*"(?<packageName>[^"]+)")?(?:\\s*,\\s*"versioning"\\s*:\\s*"(?<versioning>[^"]+)")?\\s*\\}\\s*,\\s*"url"\\s*:\\s*"[^"]+"(?:\\s*,\\s*"(?:tag|branch|commit|sha256)"\\s*:\\s*"[^"]+")+',
// Replace the pinned Git ref and commit or the release tag in the download URL and its SHA-256.
'"url"\\s*:\\s*"(?:(?:https://github[.]com/[^/"]+/[^/"]+/releases/download/(?<archiveTag>[^/"]+)/[^"]+)"\\s*,\\s*"sha256"|[^"]+"\\s*,\\s*"(?:tag|branch)"\\s*:\\s*"(?<gitRef>[^"]+)"\\s*,\\s*"commit")\\s*:\\s*"(?<currentDigest>[a-fA-F0-9]{40}(?:[a-fA-F0-9]{24})?)"',
// Read metadata and require a ref for commit-only checkouts.
'"x-renovate"\\s*:\\s*\\{\\s*"datasource"\\s*:\\s*"(?<datasource>[a-z0-9_.-]+)"\\s*,\\s*"depName"\\s*:\\s*"(?<depName>[^"]+)"(?:\\s*,\\s*"packageName"\\s*:\\s*"(?<packageName>[^"]+)")?(?:\\s*,\\s*"versioning"\\s*:\\s*"(?<versioning>[^"]+)")?(?:\\s*,\\s*"ref"\\s*:\\s*"(?<metadataRef>[^"]+)"\\s*\\}\\s*,\\s*"url"\\s*:\\s*"[^"]+"\\s*,\\s*"commit"\\s*:\\s*"[a-fA-F0-9]{40}"|\\s*\\}\\s*,\\s*"url"\\s*:\\s*"[^"]+"\\s*,\\s*"(?:tag|branch|sha256)"\\s*:\\s*"[^"]+"(?:\\s*,\\s*"commit"\\s*:\\s*"[^"]+")?)',
// Limit replacements to the source URL and its pin fields.
'"url"\\s*:\\s*"(?:(?:https://github[.]com/[^/"]+/[^/"]+/releases/download/(?<archiveTag>[^/"]+)/[^"]+)"\\s*,\\s*"sha256"|(?<gitUrl>[^"]+)"\\s*,\\s*(?:"(?:tag|branch)"\\s*:\\s*"(?<gitRef>[^"]+)"\\s*,\\s*)?"commit")\\s*:\\s*"(?<currentDigest>[a-fA-F0-9]{40}(?:[a-fA-F0-9]{24})?)"',
],
"packageNameTemplate": "{{#if packageName}}{{{packageName}}}{{else}}{{{depName}}}{{/if}}",
"versioningTemplate": "{{#if versioning}}{{{replace '(\\x5c){2}' '$1' versioning}}}{{/if}}",
"currentValueTemplate": "{{#if gitRef}}{{{gitRef}}}{{else}}{{{archiveTag}}}{{/if}}",
"packageNameTemplate": "{{#if packageName}}{{{packageName}}}{{else if metadataRef}}{{{gitUrl}}}{{else}}{{{depName}}}{{/if}}",
"versioningTemplate": "{{#if versioning}}{{{replace '(\\x5c){2}' '$1' versioning}}}{{else if metadataRef}}exact{{/if}}",
"currentValueTemplate": "{{#if gitRef}}{{{gitRef}}}{{else if metadataRef}}{{{metadataRef}}}{{else}}{{{archiveTag}}}{{/if}}",
},
],
"packageRules": [
Expand Down
100 changes: 100 additions & 0 deletions tests/renovate-config.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {resolveConfigPresets} from 'renovate/dist/config/presets/index.js';
import {init as initPresetCache} from 'renovate/dist/util/cache/memory/index.js';
import {GithubHttp} from 'renovate/dist/util/http/github.js';
import {lookupUpdates} from 'renovate/dist/workers/repository/process/lookup/index.js';
import {PackageFiles} from 'renovate/dist/workers/repository/package-files.js';
import {doAutoReplace} from 'renovate/dist/workers/repository/update/branch/auto-replace.js';
import {branchifyUpgrades} from 'renovate/dist/workers/repository/updates/branchify.js';

Expand Down Expand Up @@ -405,6 +406,105 @@ test('extracts annotated Flatpak Git pins and ignores sources without metadata',
assert.equal(deps.length, 2);
});

test('lists mixed Flatpak pins under one dashboard entry', async t => {
const packageFile = 'packaging/linux/flatpak/modules/example/dependencies.json';
const digest = 'a'.repeat(40);
const newDigest = 'b'.repeat(40);
const mirrored = {
type: 'git',
'x-renovate': {
datasource: 'git-refs',
depName: 'upstream/library',
packageName: 'https://github.com/mirror/library.git',
versioning: 'exact',
ref: 'main',
},
url: 'https://github.com/mirror/library',
commit: digest,
};
const direct = {
type: 'git',
'x-renovate': {datasource: 'git-refs', depName: 'example/helper', ref: 'stable'},
url: 'https://github.com/example/helper.git',
commit: digest,
};
const tagged = {
type: 'git',
'x-renovate': {datasource: 'github-tags', depName: 'example/tagged'},
url: 'https://github.com/example/tagged.git',
tag: 'v1.2.3',
commit: digest,
};
const branch = {
type: 'git',
'x-renovate': {
datasource: 'git-refs',
depName: 'example/branch',
packageName: 'https://github.com/example/branch.git',
versioning: 'exact',
},
url: 'https://github.com/example/branch.git',
branch: 'main',
commit: digest,
};
const archive = {
type: 'archive',
'x-renovate': {datasource: 'github-release-attachments', depName: 'example/archive'},
url: 'https://github.com/example/archive/releases/download/v1.2.3/archive.tar.gz',
sha256: 'c'.repeat(64),
};
const unrelated = {type: 'git', url: 'https://github.com/example/untracked.git', commit: digest};
const missingRef = {
...unrelated,
'x-renovate': {datasource: 'git-refs', depName: 'example/untracked'},
};
const sources = [tagged, mirrored, archive, direct, branch, unrelated, missingRef];
const content = JSON.stringify(sources, null, 2);
const config = mergeChildConfig(getConfig(), renovateConfig);
const managers = config.customManagers
.filter(manager => matchesManagerFilePattern(packageFile, manager.managerFilePatterns));
assert.equal(managers.length, 1, 'Expected one Flatpak manager for all pin types');
const [manager] = managers;
const scan = extractRegexPackageFile(content, packageFile, manager);
assert.deepEqual(scan.deps.map(summarizeDependency), [
expectedDependency('v1.2.3', 'github-tags', 'example/tagged', 'example/tagged', ''),
expectedDependency('main', 'git-refs', 'upstream/library', mirrored['x-renovate'].packageName, 'exact'),
expectedDependency('v1.2.3', 'github-release-attachments', 'example/archive', 'example/archive', ''),
expectedDependency('stable', 'git-refs', 'example/helper', direct.url, 'exact'),
expectedDependency('main', 'git-refs', 'example/branch', branch.url, 'exact'),
]);
assert.deepEqual(scan.deps.map(dep => dep.currentDigest), [digest, digest, archive.sha256, digest, digest]);
const dashboard = PackageFiles.getDashboardMarkdownInternal(
new Map([['master', {regex: [{...scan, packageFile}]}]]),
);
assert.deepEqual(dashboard.split('\n').filter(line => line.startsWith(`<details><summary>${packageFile}`)), [
`<details><summary>${packageFile} (5)</summary>`,
]);

const localDir = fs.mkdtempSync(path.join(os.tmpdir(), 'renovate-flatpak-commit-'));
const originalGlobalConfig = GlobalConfig.get();
GlobalConfig.set({...originalGlobalConfig, localDir});
t.after(() => {
GlobalConfig.set(originalGlobalConfig);
fs.rmSync(localDir, {recursive: true});
});
const updated = await doAutoReplace({
...config,
...scan,
...scan.deps[1],
manager: 'regex',
packageFile,
depIndex: 1,
newValue: 'main',
newDigest,
updateType: 'digest',
}, content, false);
assert.deepEqual(
JSON.parse(updated),
[tagged, {...mirrored, commit: newDigest}, archive, direct, branch, unrelated, missingRef],
);
});

test('updates both FFmpeg assets and the matching CPM release in one branch', async t => {
const packageFile = 'packaging/linux/flatpak/modules/ffmpeg.json';
const lockFile = 'package-lock.cmake';
Expand Down
Loading