Skip to content

Commit 89bb45b

Browse files
committed
IConfig: make project non-optional
Now that we set that information in the `defaultConfig`, and are about to make the project config itself required, there is no need for any implicit magic anymore. This change is best viewed with `--ignore-space-change`. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 3703fae commit 89bb45b

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed

lib/project-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export interface IConfig {
6666
repo: IRepoConfig;
6767
mailrepo: IMailRepoConfig;
6868
mail: IMailConfig;
69-
project?: projectInfo | undefined; // project-options values
69+
project: projectInfo; // project-options values
7070
app: IAppConfig;
7171
lint: ILintConfig;
7272
user: IUserConfig;

lib/project-options.ts

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { revParse } from "./git.js";
2-
import { IConfig, projectInfo } from "./project-config.js";
2+
import { IConfig } from "./project-config.js";
33

4-
// For now, only the Git, Cygwin and BusyBox projects are supported
54
export class ProjectOptions {
65
public static async get(
76
config: IConfig,
@@ -12,30 +11,18 @@ export class ProjectOptions {
1211
basedOn?: string,
1312
publishToRemote?: string,
1413
): Promise<ProjectOptions> {
15-
let to: string;
16-
let midUrlPrefix = " Message-ID: ";
17-
18-
if (Object.prototype.hasOwnProperty.call(config, "project")) {
19-
const project = config.project as projectInfo;
20-
to = `--to=${project.to}`;
21-
midUrlPrefix = project.urlPrefix;
22-
cc.push(...project.cc);
23-
// Hard-code a check for gitgitgadget/git whether this is a Git GUI PR
24-
// and hence needs the Git GUI maintainer to be Cc:ed
25-
if (
26-
`${config.repo.owner}/${config.repo.name}` === "gitgitgadget/git" &&
27-
(await revParse(`${baseCommit}:git-gui.sh`, workDir)) !== undefined
28-
) {
29-
} else if ((await revParse(`${baseCommit}:winsup`, workDir)) !== undefined) {
30-
// Cygwin
31-
32-
midUrlPrefix = "https://www.mail-archive.com/[email protected]&q=";
33-
} else if ((await revParse(`${baseCommit}:include/busybox.h`, workDir)) !== undefined) {
34-
// BusyBox
35-
36-
midUrlPrefix = "https://www.mail-archive.com/[email protected]&q=";
37-
} else {
38-
throw new Error("Unrecognized project");
14+
const to = `--to=${config.project.to}`;
15+
const midUrlPrefix = config.project.urlPrefix;
16+
cc.push(...config.project.cc);
17+
18+
// Hard-code a check for gitgitgadget/git whether this is a Git GUI PR
19+
// and hence needs the Git GUI maintainer to be Cc:ed
20+
if (
21+
`${config.repo.owner}/${config.repo.name}` === "gitgitgadget/git" &&
22+
(await revParse(`${baseCommit}:git-gui.sh`, workDir)) !== undefined
23+
) {
24+
// Git GUI
25+
cc.push("Johannes Sixt <[email protected]>");
3926
}
4027

4128
return new ProjectOptions(branchName, basedOn, publishToRemote, to, cc, midUrlPrefix, workDir, baseCommit);

tests/test-lib.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export const testConfig = {
1111
...defaultConfig,
1212
// We're running in the test suite!
1313
project: {
14-
cc: [],
1514
...defaultConfig.project,
1615
1716
urlPrefix: "https://dummy.com/?mid=",

0 commit comments

Comments
 (0)