Skip to content

Commit 5323496

Browse files
committed
feat: reconstruct-chromium-version command
1 parent 5b80e17 commit 5323496

File tree

4 files changed

+378
-58
lines changed

4 files changed

+378
-58
lines changed

src/e

+6-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ program
179179
'Opens a PR to electron/electron that backport the given CL into our patches folder',
180180
)
181181
.alias('auto-cherry-pick')
182-
.command('gh-auth', 'Generates a device oauth token');
182+
.command('gh-auth', 'Generates a device oauth token')
183+
.command(
184+
'rcv <roll-pr> [chromium-version]',
185+
'Attempts to reconstruct an intermediate Chromium version from a roll PR',
186+
)
187+
.alias('reconstruct-chromium-version');
183188

184189
program
185190
.command('load-macos-sdk')

src/e-cherry-pick.js

-57
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const path = require('path');
88
const os = require('os');
99
const { Octokit } = require('@octokit/rest');
1010

11-
const { getCveForBugNr } = require('./utils/crbug');
1211
const { getGitHubAuthToken } = require('./utils/github-auth');
1312
const { fatal, color } = require('./utils/logging');
1413

@@ -17,14 +16,6 @@ const ELECTRON_REPO_DATA = {
1716
repo: 'electron',
1817
};
1918

20-
const gerritSources = [
21-
'chromium-review.googlesource.com',
22-
'skia-review.googlesource.com',
23-
'webrtc-review.googlesource.com',
24-
'pdfium-review.googlesource.com',
25-
'dawn-review.googlesource.com',
26-
];
27-
2819
async function getPatchDetailsFromURL(urlStr, security) {
2920
const parsedUrl = new URL(urlStr);
3021
if (parsedUrl.host.endsWith('.googlesource.com')) {
@@ -38,54 +29,6 @@ async function getPatchDetailsFromURL(urlStr, security) {
3829
);
3930
}
4031

41-
async function getGerritPatchDetailsFromURL(gerritUrl, security) {
42-
const { host, pathname } = gerritUrl;
43-
44-
if (!gerritSources.includes(host)) {
45-
fatal('Unsupported gerrit host');
46-
}
47-
const [, repo, number] = /^\/c\/(.+?)\/\+\/(\d+)/.exec(pathname);
48-
49-
d(`fetching patch from gerrit`);
50-
const changeId = `${repo}~${number}`;
51-
const patchUrl = new URL(
52-
`/changes/${encodeURIComponent(changeId)}/revisions/current/patch`,
53-
gerritUrl,
54-
);
55-
56-
const patch = await fetch(patchUrl)
57-
.then((resp) => resp.text())
58-
.then((text) => Buffer.from(text, 'base64').toString('utf8'));
59-
60-
const [, commitId] = /^From ([0-9a-f]+)/.exec(patch);
61-
62-
const bugNumber =
63-
/^(?:Bug|Fixed)[:=] ?(.+)$/im.exec(patch)?.[1] || /^Bug= ?chromium:(.+)$/m.exec(patch)?.[1];
64-
65-
let cve = '';
66-
if (security) {
67-
try {
68-
cve = await getCveForBugNr(bugNumber.replace('chromium:', ''));
69-
} catch (err) {
70-
d(err);
71-
console.error(
72-
`${color.warn} Failed to fetch CVE for ${bugNumber} - you'll need to find it manually`,
73-
);
74-
}
75-
}
76-
77-
const patchDirName =
78-
{
79-
'chromium-review.googlesource.com:chromium/src': 'chromium',
80-
'skia-review.googlesource.com:skia': 'skia',
81-
'webrtc-review.googlesource.com:src': 'webrtc',
82-
}[`${host}:${repo}`] || repo.split('/').reverse()[0];
83-
84-
const shortCommit = commitId.substr(0, 12);
85-
86-
return { patchDirName, shortCommit, patch, bugNumber, cve };
87-
}
88-
8932
async function getGitHubPatchDetailsFromURL(gitHubUrl, security) {
9033
if (security) {
9134
fatal('GitHub cherry-picks can not be security backports currently');

0 commit comments

Comments
 (0)