TypeScript
fix(github): Enterprise Server pull request URLs can be pasted to check out (#29892)
Alex Southwell40aba09b445f
diff --git a/packages/client-runtime/src/pullRequestLinkInput.test.ts b/packages/client-runtime/src/pullRequestLinkInput.test.tsindex 49404975ab6..9cc80830efe 100644--- a/packages/client-runtime/src/pullRequestLinkInput.test.ts+++ b/packages/client-runtime/src/pullRequestLinkInput.test.ts@@ -173,6 +173,14 @@ describe("parsePullRequestReference", () => {expect(parsePullRequestReference(url)).toBe(url);});+ it.each([+ "https://github.acme.test/acme/web/pull/42",+ "https://git.corp.example/acme/web/pull/42/files?diff=split",+ ])("accepts GitHub Enterprise Server pull request URL %s", (url) => {+ expect(parsePullRequestReference(url)).toBe(url);+ expect(parsePullRequestReference(`gh pr checkout ${url}`)).toBe(url);+ });+it("accepts gh pr checkout commands with raw numbers", () => {expect(parsePullRequestReference("gh pr checkout 42")).toBe("42");});diff --git a/packages/source-control-github/src/shared/definition.ts b/packages/source-control-github/src/shared/definition.tsindex 8244e10d9e7..3c33cfb3a3f 100644--- a/packages/source-control-github/src/shared/definition.ts+++ b/packages/source-control-github/src/shared/definition.ts@@ -19,7 +19,7 @@ import { gitHubReferenceAutolinks } from "./referenceAutolinks.ts";const CHECKOUT_COMMAND = /^gh\s+pr\s+checkout\s+(.+)$/i;const CHANGE_REQUEST_REFERENCE =- /^https:\/\/github\.com\/[^/\s]+\/[^/\s]+\/pull\/(\d+)(?:[/?#].*)?$/i;+ /^https?:\/\/[^/?#\s]+\/[^/\s]+\/[^/\s]+\/pull\/(\d+)(?:[/?#].*)?$/i;// GitHub Enterprise Server runs on any hostname, so the `<owner>/<repo>/pull/<n>` route alone// identifies a GitHub pull request.