Skip to content

Commit 0d39e87

Browse files
committed
ProjectOptions: adjust misnomer
Already in b46912d (PatchSeries: allow initializing from notes, 2018-05-31), the `ProjectOptions` instance that gets constructed when initializing from Git notes receives the `headCommit` as `branchName` parameter. Therefore, that name is misleading. Let's rename the parameter to `headCommit`, to reflect what is being passed in. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 79490a3 commit 0d39e87

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

lib/patch-series.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ export class PatchSeries {
570570
): Promise<IPatchSeriesMetadata | undefined> {
571571
let globalOptions: IGitGitGadgetOptions | undefined;
572572
if (this.options.dryRun) {
573-
logger.log(`Dry-run ${this.project.branchName} v${this.metadata.iteration}`);
573+
logger.log(`Dry-run ${this.project.headCommit} v${this.metadata.iteration}`);
574574
} else {
575-
logger.log(`Submitting ${this.project.branchName} v${this.metadata.iteration}`);
575+
logger.log(`Submitting ${this.project.headCommit} v${this.metadata.iteration}`);
576576
globalOptions = await this.notes.get<IGitGitGadgetOptions>("");
577577
}
578578

@@ -645,7 +645,7 @@ export class PatchSeries {
645645
);
646646
let tagName: string | undefined;
647647
if (!this.metadata.pullRequestURL) {
648-
tagName = `${this.project.branchName}-v${this.metadata.iteration}`;
648+
tagName = `${this.project.headCommit}-v${this.metadata.iteration}`;
649649
} else {
650650
const prKey = getPullRequestKeyFromURL(this.metadata.pullRequestURL);
651651
const branch = this.metadata.headLabel.replace(/:/g, "/");
@@ -816,7 +816,7 @@ export class PatchSeries {
816816
}
817817

818818
if (!this.options.dryRun) {
819-
const key = this.metadata.pullRequestURL || this.project.branchName;
819+
const key = this.metadata.pullRequestURL || this.project.headCommit;
820820
await this.notes.set(key, this.metadata, true);
821821
}
822822

@@ -847,7 +847,7 @@ export class PatchSeries {
847847
}
848848

849849
protected async generateMBox(): Promise<string> {
850-
const mergeBase = await git(["merge-base", this.project.baseCommit, this.project.branchName], {
850+
const mergeBase = await git(["merge-base", this.project.baseCommit, this.project.headCommit], {
851851
workDir: this.project.workDir,
852852
});
853853
const args = [
@@ -874,15 +874,15 @@ export class PatchSeries {
874874
}
875875
if (this.patchCount > 1) {
876876
if (!this.coverLetter) {
877-
throw new Error(`Branch ${this.project.branchName} needs a description`);
877+
throw new Error(`Branch ${this.project.headCommit} needs a description`);
878878
}
879879
args.push("--cover-letter");
880880
}
881881
if (this.options.patience) {
882882
args.push("--patience");
883883
}
884884

885-
args.push(`${this.project.baseCommit}..${this.project.branchName}`);
885+
args.push(`${this.project.baseCommit}..${this.project.headCommit}`);
886886

887887
return await git(args, { workDir: this.project.workDir });
888888
}

lib/project-options.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class ProjectOptions {
55
public static async get(
66
config: IConfig,
77
workDir: string,
8-
branchName: string,
8+
headCommit: string,
99
cc: string[],
1010
baseCommit: string,
1111
basedOn?: string,
@@ -24,10 +24,10 @@ export class ProjectOptions {
2424
cc.push("Johannes Sixt <[email protected]>");
2525
}
2626

27-
return new ProjectOptions(branchName, basedOn, to, cc, midUrlPrefix, workDir, baseCommit);
27+
return new ProjectOptions(headCommit, basedOn, to, cc, midUrlPrefix, workDir, baseCommit);
2828
}
2929

30-
public readonly branchName: string;
30+
public readonly headCommit: string;
3131
public readonly baseCommit: string;
3232
public readonly basedOn?: string;
3333
public readonly workDir: string;
@@ -37,15 +37,15 @@ export class ProjectOptions {
3737
public readonly midUrlPrefix: string;
3838

3939
protected constructor(
40-
branchName: string,
40+
headCommit: string,
4141
basedOn: string | undefined,
4242
to: string,
4343
cc: string[],
4444
midUrlPrefix: string,
4545
workDir: string,
4646
baseCommit: string,
4747
) {
48-
this.branchName = branchName;
48+
this.headCommit = headCommit;
4949

5050
this.baseCommit = baseCommit;
5151

tests/project-options.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ test("project options", async () => {
3838
const prMeta = {
3939
baseCommit: options2.baseCommit,
4040
baseLabel: "upstream/main",
41-
headCommit: options2.branchName,
42-
headLabel: options2.branchName,
41+
headCommit: options2.headCommit,
42+
headLabel: options2.headCommit,
4343
iteration: 1,
4444
};
4545
const x = new X(testConfig, new GitNotes(repo.workDir), {}, options2, prMeta, undefined, 1);

0 commit comments

Comments
 (0)