Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 2904c54

Browse files
authored
Merge pull request #157 from BenediktMagnus/master
Support remotes with configurable names
2 parents 6dbdede + 284f982 commit 2904c54

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
"description": "Whether org features should be enabled. Requires the `admin:org` scope",
5555
"default": false,
5656
"scope": "window"
57+
},
58+
"github-actions.remote-name": {
59+
"type": "string",
60+
"description": "The name of the repository's git remote that points to GitHub",
61+
"default": "origin",
62+
"scope": "window"
5763
}
5864
}
5965
},

src/configuration/configuration.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,10 @@ export async function updateOrgFeaturesEnabled(enabled: boolean) {
7777
true
7878
);
7979
}
80+
81+
export function getRemoteName(): string {
82+
return getConfiguration().get<string>(
83+
getSettingsKey("remote-name"),
84+
"origin"
85+
);
86+
}

src/git/repository.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Octokit } from "@octokit/rest";
77
import { Protocol } from "../external/protocol";
88
import { getClient } from "../api/api";
99
import { getSession } from "../auth/auth";
10+
import { getRemoteName } from "../configuration/configuration";
1011

1112
async function getGitExtension(): Promise<API | undefined> {
1213
const gitExtension =
@@ -58,15 +59,15 @@ export async function getGitHubUrls(): Promise<
5859
if (git && git.repositories.length > 0) {
5960
logDebug("Found git extension");
6061

62+
const remoteName = getRemoteName();
63+
6164
const p = await Promise.all(
6265
git.repositories.map(async (r) => {
6366
logDebug("Find `origin` remote for repository", r.rootUri.path);
6467
await r.status();
6568

66-
// In the future we might make this configurable, but for now continue to look
67-
// for a remote named "origin".
6869
const originRemote = r.state.remotes.filter(
69-
(remote) => remote.name === "origin"
70+
(remote) => remote.name === remoteName
7071
);
7172
if (
7273
originRemote.length > 0 &&
@@ -81,7 +82,7 @@ export async function getGitHubUrls(): Promise<
8182
};
8283
}
8384

84-
logDebug("No `origin` remote found, skipping repository");
85+
logDebug(`Remote "${remoteName}" not found, skipping repository`);
8586

8687
return undefined;
8788
})

0 commit comments

Comments
 (0)