Skip to content

Commit 2e63bf5

Browse files
committed
ProjectOptions: baseCommit is actually mandatory
Back in the days when I tried to maintain a Command-Line Interface in GitGitGadget to replace my `mail-patch-series.sh` script (still available at https://github.com/dscho/mail-patch-series, it was the predecessor of GitGitGadget that worked on local repositories instead of Pull Requests), there was not necessarily a `baseCommit` to work with: local branches can have an upstream branch (configured via `git branch --set-upstream-to=<remote>/<branch>`). But I removed support for this way to call GitGitGadget in 6d397b0 (Remove support for the CLI mode, 2023-12-31), so now there always is a `baseCommit`. Let's make it mandatory, so that it can eventually take on the role of the `upstreamBranch` (which we can then remove). Since optional parameters must come after non-optional ones, this unfortunately requires a reordering of the (positional) parameters of the `ProjectOptions.get()` function. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 5368980 commit 2e63bf5

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

lib/patch-series.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export class PatchSeries {
140140

141141
const publishToRemote: string | undefined = undefined;
142142

143-
const project = await ProjectOptions.get(config, workDir, headCommit, cc, basedOn, publishToRemote, baseCommit);
143+
const project = await ProjectOptions.get(config, workDir, headCommit, cc, baseCommit, basedOn, publishToRemote);
144144
if (rangeDiff) {
145145
options.rangeDiff = rangeDiff;
146146
}

lib/project-options.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export class ProjectOptions {
88
workDir: string,
99
branchName: string,
1010
cc: string[],
11+
baseCommit: string,
1112
basedOn?: string,
1213
publishToRemote?: string,
13-
baseCommit?: string,
1414
): Promise<ProjectOptions> {
1515
let upstreamBranch: string;
1616
let to: string;
@@ -70,7 +70,7 @@ export class ProjectOptions {
7070

7171
return new ProjectOptions(
7272
branchName,
73-
upstreamBranch,
73+
baseCommit,
7474
basedOn,
7575
publishToRemote,
7676
to,
@@ -101,12 +101,12 @@ export class ProjectOptions {
101101
cc: string[],
102102
midUrlPrefix: string,
103103
workDir: string,
104-
baseCommit?: string,
104+
baseCommit: string,
105105
) {
106106
this.branchName = branchName;
107107
this.upstreamBranch = upstreamBranch;
108108

109-
this.baseCommit = baseCommit || upstreamBranch;
109+
this.baseCommit = baseCommit;
110110

111111
this.basedOn = basedOn;
112112
this.publishToRemote = publishToRemote;

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
@@ -28,9 +28,9 @@ test("project options", async () => {
2828
repo.workDir,
2929
"test-project-options",
3030
["Nguyễn Thái Ngọc Duy <[email protected]>"],
31+
"test-project-options^",
3132
undefined,
3233
undefined,
33-
"test-project-options^",
3434
);
3535
expect(options2.workDir).not.toBeUndefined();
3636
expect(options2.midUrlPrefix).toEqual("https://dummy.com/?mid=");

0 commit comments

Comments
 (0)