Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): fall back to plain `gh auth status` on CLIs without --json #3943

Closedwebdevtodayjason(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/3943/headopened View on GitHub

Showing 5 changed files with 217 additions and 3 deletions (loading 2).

x
0 of 5 viewed, 5 left
64 additions and 1 deletionapps/server/src/sourceControl/GitHubSourceControlProvider.test.tsModified
View file
@@ -7,7 +7,7 @@
​
import * as VcsProcess from "../vcs/VcsProcess.ts";
import * as GitHubCli from "./GitHubCli.ts";
-import { parseGitHubAuthStatus } from "./gitHubAuthStatus.ts";
+import { parseGitHubAuthStatus, parseGitHubAuthStatusText } from "./gitHubAuthStatus.ts";
import * as GitHubSourceControlProvider from "./GitHubSourceControlProvider.ts";
​
const processResult = (
@@ -381,3 +381,66 @@
});
+​
+it("parses the plain-text auth status emitted by CLIs without --json support", () => {
+ const auth = GitHubSourceControlProvider.discovery.parseAuth(
+ processResult(
+ [
+ "github.com",
+ " \u2713 Logged in to github.com account octocat (/home/user/.config/gh/hosts.yml)",
+ " - Active account: true",
+ " - Token: gho_************",
+ ].join("\n"),
+ ),
+ );
+​
+ assert.deepStrictEqual(auth, {
+ status: "authenticated",
+ account: Option.some("octocat"),