Skip to content
TypeScript

fix(web): name the missing repository in the PR link dialog (#20533)

Scott Nortemanc7a2fdc6e349
diff --git a/packages/client-runtime/src/pullRequestLinkInput.test.ts b/packages/client-runtime/src/pullRequestLinkInput.test.ts
index 47896c0d9ff..74cdad9f336 100644
--- a/packages/client-runtime/src/pullRequestLinkInput.test.ts
+++ b/packages/client-runtime/src/pullRequestLinkInput.test.ts
@@ -114,11 +114,17 @@ describe("resolveLinkPullRequestInput", () => {
expect(result).toMatchObject({ error: expect.stringContaining("gitlab.com") });
});
- it("asks for a URL when a bare number has no project to resolve against", () => {
- expect(
- resolveLinkPullRequestInput({ reference: "12", project: null, hasProject: () => true }),
- ).toMatchObject({ error: expect.stringContaining("full URL") });
- });
+ it.each(["12", "#12"])(
+ "names the missing repository when resolving bare number %s",
+ (reference) => {
+ expect(
+ resolveLinkPullRequestInput({ reference, project: null, hasProject: () => true }),
+ ).toEqual({
+ error:
+ "Paste the full pull request URL; this thread has no repository to resolve the number against.",
+ });
+ },
+ );
it("accepts a checkout command as a reference", () => {
expect(
diff --git a/packages/client-runtime/src/pullRequestLinkInput.ts b/packages/client-runtime/src/pullRequestLinkInput.ts
index a6d4d4ce8d8..a72701adc90 100644
--- a/packages/client-runtime/src/pullRequestLinkInput.ts
+++ b/packages/client-runtime/src/pullRequestLinkInput.ts
@@ -91,7 +91,10 @@ export function resolveLinkPullRequestInput(input: {
const number = Number(parsed);
if (!Number.isSafeInteger(number) || number < 1) return null;
if (input.project === null) {
- return { error: "Paste a full URL to link a pull request from another repository." };
+ return {
+ error:
+ "Paste the full pull request URL; this thread has no repository to resolve the number against.",
+ };
}
const webUrl = input.project.webUrl(number);
const webReference = webUrl === null ? null : parseChangeRequestUrl(webUrl);