Skip to content

Commit aa71b44

Browse files
committed
IConfig: remove no longer needed project.branch
Ever since 6d397b0 (Remove support for the CLI mode, 2023-12-31), there is no way the `ProjectOptions` are constructed without a `baseCommit`. Therefore it is always provided. And since `baseCommit` is always provided, the `ProjectOptions.get()` function no longer needs `upstreamBranch`: It only used it in a "is this rebased?" check that apparently hasn't been called anymore, ever. So that leaves just one last user of that `upstreamBranch` attribute, but that's a test that wants to mocj a `prMeta` from a `ProjectOptions` instance, something that only the CLI mode used to do, but no remaining production code. That test can easily replace that `options2.upstreamBranch` with a sensible, hard-coded string. And since that's gone, we can also remove the `project.branch` attribute because nothing uses it anymore. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 2e63bf5 commit aa71b44

File tree

4 files changed

+4
-39
lines changed

4 files changed

+4
-39
lines changed

lib/project-config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export type projectInfo = {
22
to: string; // email to send patches to
3-
branch: string; // upstream branch a PR must be based on
43
cc: string[]; // emails to always be copied on patches
54
urlPrefix: string; // url to 'listserv' of mail (should it be in mailrepo?)
65
};

lib/project-options.ts

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { commitExists, git, revParse } from "./git.js";
1+
import { commitExists, revParse } from "./git.js";
22
import { IConfig, projectInfo } from "./project-config.js";
33

44
// For now, only the Git, Cygwin and BusyBox projects are supported
@@ -12,14 +12,12 @@ export class ProjectOptions {
1212
basedOn?: string,
1313
publishToRemote?: string,
1414
): Promise<ProjectOptions> {
15-
let upstreamBranch: string;
1615
let to: string;
1716
let midUrlPrefix = " Message-ID: ";
1817

1918
if (Object.prototype.hasOwnProperty.call(config, "project")) {
2019
const project = config.project as projectInfo;
2120
to = `--to=${project.to}`;
22-
upstreamBranch = project.branch;
2321
midUrlPrefix = project.urlPrefix;
2422
for (const user of project.cc) {
2523
cc.push(user);
@@ -28,61 +26,31 @@ export class ProjectOptions {
2826
// Git GUI
2927
3028
cc.push("Johannes Sixt <[email protected]>");
31-
upstreamBranch = "git-gui/master";
3229
} else if ((await revParse(`${baseCommit}:git.c`, workDir)) !== undefined) {
3330
// Git
3431
3532
// Do *not* Cc: Junio Hamano by default
36-
upstreamBranch = "upstream/seen";
37-
if (await git(["rev-list", branchName + ".." + upstreamBranch], { workDir })) {
38-
upstreamBranch = "upstream/next";
39-
}
40-
if (await git(["rev-list", branchName + ".." + upstreamBranch], { workDir })) {
41-
upstreamBranch = "upstream/master";
42-
}
4333
midUrlPrefix = "https://lore.kernel.org/git/";
4434
} else if ((await revParse(`${baseCommit}:winsup`, workDir)) !== undefined) {
4535
// Cygwin
4636
47-
upstreamBranch = "cygwin/master";
4837
midUrlPrefix = "https://www.mail-archive.com/[email protected]&q=";
4938
} else if ((await revParse(`${baseCommit}:include/busybox.h`, workDir)) !== undefined) {
5039
// BusyBox
5140
52-
upstreamBranch = "busybox/master";
5341
midUrlPrefix = "https://www.mail-archive.com/[email protected]&q=";
5442
} else if (await commitExists("7ccd18012de2e6c47e5", workDir)) {
5543
// We're running in the test suite!
5644
57-
upstreamBranch = "master";
5845
midUrlPrefix = "https://dummy.com/?mid=";
5946
} else {
6047
throw new Error("Unrecognized project");
6148
}
6249

63-
if (basedOn) {
64-
upstreamBranch = basedOn;
65-
}
66-
67-
if (!baseCommit && (await git(["rev-list", branchName + ".." + upstreamBranch], { workDir }))) {
68-
throw new Error(`Branch ${branchName} is not rebased to ${upstreamBranch}`);
69-
}
70-
71-
return new ProjectOptions(
72-
branchName,
73-
baseCommit,
74-
basedOn,
75-
publishToRemote,
76-
to,
77-
cc,
78-
midUrlPrefix,
79-
workDir,
80-
baseCommit,
81-
);
50+
return new ProjectOptions(branchName, basedOn, publishToRemote, to, cc, midUrlPrefix, workDir, baseCommit);
8251
}
8352

8453
public readonly branchName: string;
85-
public readonly upstreamBranch: string;
8654
public readonly baseCommit: string;
8755
public readonly basedOn?: string;
8856
public readonly publishToRemote?: string;
@@ -94,7 +62,6 @@ export class ProjectOptions {
9462

9563
protected constructor(
9664
branchName: string,
97-
upstreamBranch: string,
9865
basedOn: string | undefined,
9966
publishToRemote: string | undefined,
10067
to: string,
@@ -104,7 +71,6 @@ export class ProjectOptions {
10471
baseCommit: string,
10572
) {
10673
this.branchName = branchName;
107-
this.upstreamBranch = upstreamBranch;
10874

10975
this.baseCommit = baseCommit;
11076

tests/patch-series.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class PatchSeriesTest extends PatchSeries {
9696
};
9797
class ProjectOptionsTest extends ProjectOptions {
9898
public constructor() {
99-
super("", "", "", "", "", [], "", "", "");
99+
super("", "", "", "", [], "", "", "");
100100
}
101101
}
102102

tests/project-options.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ test("project options", async () => {
3939
public static async test(): Promise<void> {
4040
const prMeta = {
4141
baseCommit: options2.baseCommit,
42-
baseLabel: options2.upstreamBranch,
42+
baseLabel: "upstream/main",
4343
headCommit: options2.branchName,
4444
headLabel: options2.branchName,
4545
iteration: 1,

0 commit comments

Comments
 (0)