Skip to content

Commit 3e65c68

Browse files
committed
IConfig: move repo.owners to a better place
The `owners` array refers to a list of orgs/owners where the GitHub App is installed, i.e. where GitGitGadget can operate. Therefore, a much better place is `app.installedOn`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 1bad447 commit 3e65c68

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

lib/ci-helper.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class CIHelper {
175175
console.time("get open PR head commits");
176176
const openPRCommits = (
177177
await Promise.all(
178-
this.config.repo.owners.map(async (repositoryOwner) => {
178+
this.config.app.installedOn.map(async (repositoryOwner) => {
179179
return await this.github.getOpenPRs(repositoryOwner);
180180
}),
181181
)
@@ -256,7 +256,7 @@ export class CIHelper {
256256
const prCommentUrl = core.getInput("pr-comment-url");
257257
const [, owner, repo, prNumber, commentId] =
258258
prCommentUrl.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)#issuecomment-(\d+)$/) || [];
259-
if (!this.config.repo.owners.includes(owner) || repo !== this.config.repo.name) {
259+
if (!this.config.app.installedOn.includes(owner) || repo !== this.config.repo.name) {
260260
throw new Error(`Invalid PR comment URL: ${prCommentUrl}`);
261261
}
262262
return { owner, repo, prNumber: parseInt(prNumber, 10), commentId: parseInt(commentId, 10) };
@@ -266,7 +266,7 @@ export class CIHelper {
266266
const prUrl = core.getInput("pr-url");
267267

268268
const [, owner, repo, prNumber] = prUrl.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)$/) || [];
269-
if (!this.config.repo.owners.includes(owner) || repo !== this.config.repo.name) {
269+
if (!this.config.app.installedOn.includes(owner) || repo !== this.config.repo.name) {
270270
throw new Error(`Invalid PR URL: ${prUrl}`);
271271
}
272272
return { owner, repo, prNumber: parseInt(prNumber, 10) };
@@ -1137,7 +1137,7 @@ export class CIHelper {
11371137
const handledPRs = new Set<string>();
11381138
const handledMessageIDs = new Set<string>();
11391139

1140-
for (const repositoryOwner of this.config.repo.owners) {
1140+
for (const repositoryOwner of this.config.app.installedOn) {
11411141
const pullRequests = await this.github.getOpenPRs(repositoryOwner);
11421142

11431143
for (const pr of pullRequests) {
@@ -1195,7 +1195,7 @@ export class CIHelper {
11951195
private async getPRInfo(prKey: pullRequestKey): Promise<IPullRequestInfo> {
11961196
const pr = await this.github.getPRInfo(prKey);
11971197

1198-
if (!this.config.repo.owners.includes(pr.baseOwner) || pr.baseRepo !== this.config.repo.name) {
1198+
if (!this.config.app.installedOn.includes(pr.baseOwner) || pr.baseRepo !== this.config.repo.name) {
11991199
throw new Error(`Unsupported repository: ${pr.pullRequestURL}`);
12001200
}
12011201

lib/gitgitgadget-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const defaultConfig: IConfig = {
66
owner: "gitgitgadget",
77
upstreamOwner: "git",
88
testOwner: "dscho",
9-
owners: ["gitgitgadget", "git", "dscho"],
109
branches: ["maint", "seen"],
1110
closingBranches: ["maint", "master"],
1211
trackingBranches: ["maint", "seen", "master", "next"],
@@ -36,6 +35,7 @@ const defaultConfig: IConfig = {
3635
name: "gitgitgadget",
3736
displayName: "GitGitGadget",
3837
altname: "gitgitgadget-git",
38+
installedOn: ["gitgitgadget", "git", "dscho"],
3939
},
4040
lint: {
4141
maxCommitsIgnore: ["https://github.com/gitgitgadget/git/pull/923"],

lib/project-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export interface IConfig {
1414
owner: string; // owner of repo holding the notes (tracking data)
1515
upstreamOwner: string; // owner of upstream ("base") repo
1616
testOwner?: string; // owner of the test repo (if any)
17-
owners: string[]; // owners of clones being monitored (PR checking)
1817
branches: string[]; // remote branches to fetch - just use trackingBranches?
1918
closingBranches: string[]; // close if the pr is added to this branch
2019
trackingBranches: string[]; // comment if the pr is added to this branch
@@ -44,6 +43,7 @@ export interface IConfig {
4443
installationID: number;
4544
name: string;
4645
displayName: string; // name to use in comments to identify app
46+
installedOn: string[]; // owners of clones being monitored (PR checking)
4747
altname: string | undefined; // is this even needed?
4848
};
4949
lint: {

tests-config/ci-helper.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const testConfig: IConfig = {
1717
name: "telescope",
1818
owner: "webb",
1919
upstreamOwner: "galileo",
20-
owners: ["webb", "galileo"],
2120
branches: ["maint"],
2221
closingBranches: ["maint", "main"],
2322
trackingBranches: ["maint", "main", "hubble"],
@@ -41,7 +40,8 @@ const testConfig: IConfig = {
4140
installationID: 195971,
4241
name: "gitgitgadget",
4342
displayName: "BigScopes",
44-
altname: "gitgitgadget-git"
43+
altname: "gitgitgadget-git",
44+
installedOn: ["webb", "galileo"],
4545
},
4646
lint: {
4747
maxCommitsIgnore: [],

0 commit comments

Comments
 (0)