fix(server): outdated gh no longer reads as "not authenticated" (#7588)
This commit is contained in:
1 parent
8c85b4933f
commit
51341f2ac1
4 files changed
+29
-2
No files matched your search
@@ -381,3 +381,18 @@ it("reports unauthenticated when GitHub JSON has accounts but none are valid", (
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("reports an update hint instead of unauthenticated when gh predates --json", () => {
|
||||
const auth = GitHubSourceControlProvider.discovery.parseAuth(
|
||||
processResult("", {
|
||||
stderr: "unknown flag: --json\n\nUsage: gh auth status [flags]\n",
|
||||
exitCode: ChildProcessSpawner.ExitCode(1),
|
||||
}),
|
||||
);
|
||||
|
||||
assert.strictEqual(auth.status, "unknown");
|
||||
assert.match(
|
||||
Option.getOrElse(auth.detail, () => ""),
|
||||
/2\.81\.0/,
|
||||
);
|
||||
});
|
||||
@@ -67,6 +67,16 @@ function parseGitHubAuth(input: SourceControlAuthProbeInput) {
|
||||
});
|
||||
}
|
||||
|
||||
// gh gained `auth status --json` in 2.81.0. Older versions reject the flag and exit
|
||||
// non-zero, which reads exactly like a signed-out CLI. Name the real problem instead.
|
||||
if (input.exitCode !== 0 && output.includes("unknown flag: --json")) {
|
||||
return providerAuth({
|
||||
status: "unknown",
|
||||
detail:
|
||||
"GitHub CLI is too old to report sign-in status. Update `gh` to 2.81.0 or newer (for example `brew upgrade gh`) and rescan.",
|
||||
});
|
||||
}
|
||||
|
||||
if (input.exitCode !== 0) {
|
||||
return providerAuth({
|
||||
status: "unauthenticated",
|
||||
|
||||
Reference in new issue
Block a user