Skip to content
Snippets Groups Projects
Unverified Commit 9aaadd1f authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

feat: sourceRepoSlug (#9916)

parent 1bc09b0b
No related branches found
No related tags found
No related merge requests found
......@@ -88,6 +88,7 @@ export const allowedFields = {
releaseNotes: 'A ChangeLogNotes object for the release',
repository: 'The current repository',
semanticPrefix: 'The fully generated semantic prefix for commit messages',
sourceRepoSlug: 'The slugified pathname of the sourceUrl, if present',
sourceUrl: 'The source URL for the package',
updateType: 'One of digest, pin, rollback, patch, minor, major',
upgrades: 'An array of upgrade objects in the branch',
......
......@@ -44,8 +44,24 @@ describe(getName(), () => {
packageFile: 'package.json',
lockFiles: ['package-lock.json'],
deps: [
{ depName: '@org/a', updates: [{ newValue: '1.0.0' }] },
{ depName: 'foo', updates: [{ newValue: '2.0.0' }] },
{
depName: '@org/a',
updates: [
{
newValue: '1.0.0',
sourceUrl: 'https://github.com/org/repo',
},
],
},
{
depName: 'foo',
updates: [
{
newValue: '2.0.0',
sourceUrl: 'https://github.com/org/repo',
},
],
},
{
updateTypes: ['pin'],
updates: [{ newValue: '2.0.0' }],
......@@ -54,7 +70,12 @@ describe(getName(), () => {
},
{
packageFile: 'backend/package.json',
deps: [{ depName: 'bar', updates: [{ newValue: '3.0.0' }] }],
deps: [
{
depName: 'bar',
updates: [{ newValue: '3.0.0', sourceUrl: 3 }],
},
],
},
{
packageFile: 'frontend/package.json',
......@@ -68,6 +89,7 @@ describe(getName(), () => {
{
depName: 'amd64/node',
language: LANGUAGE_DOCKER,
sourceUrl: 'https://github.com/nodejs/node',
updates: [{ newValue: '10.0.1' }],
},
],
......@@ -78,6 +100,7 @@ describe(getName(), () => {
{
depName: 'calico/node',
language: LANGUAGE_DOCKER,
sourceUrl: 'https://calico.com',
updates: [{ newValue: '3.2.0', updateType: 'minor' }],
},
],
......@@ -109,6 +132,7 @@ describe(getName(), () => {
};
const res = await flattenUpdates(config, packageFiles);
expect(res).toHaveLength(13);
expect(res.filter((update) => update.sourceRepoSlug)).toHaveLength(3);
expect(
res.filter((r) => r.updateType === 'lockFileMaintenance')
).toHaveLength(2);
......
......@@ -7,6 +7,7 @@ import type { RenovateConfig } from '../../../config/types';
import { getDefaultConfig } from '../../../datasource';
import { get } from '../../../manager';
import { applyPackageRules } from '../../../util/package-rules';
import { parseUrl } from '../../../util/url';
import type { BranchUpgradeConfig } from '../../types';
import { generateBranchName } from './branch-name';
......@@ -26,6 +27,15 @@ export function applyUpdateConfig(input: BranchUpgradeConfig): any {
.replace(/-+/, '-')
.toLowerCase()
: undefined;
if (updateConfig.sourceUrl) {
const parsedSourceUrl = parseUrl(updateConfig.sourceUrl);
if (parsedSourceUrl?.pathname) {
updateConfig.sourceRepoSlug = parsedSourceUrl.pathname
.replace(/^\//, '') // remove leading slash
.replace(/\//g, '-') // change slashes to hyphens
.replace(/-+/g, '-'); // remove multiple hyphens
}
}
generateBranchName(updateConfig);
return updateConfig;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment