From 2ea5f03b43db7a8eb33bf44b31969ecb341fc5ae Mon Sep 17 00:00:00 2001 From: t4kamura Date: Mon, 18 Mar 2024 22:49:07 +0900 Subject: [PATCH 1/2] Test pr url lock --- pkg/cmd/issue/shared/lookup_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/cmd/issue/shared/lookup_test.go b/pkg/cmd/issue/shared/lookup_test.go index 694a3fd05..44f496de4 100644 --- a/pkg/cmd/issue/shared/lookup_test.go +++ b/pkg/cmd/issue/shared/lookup_test.go @@ -79,6 +79,23 @@ func TestIssueFromArgWithFields(t *testing.T) { wantIssue: 13, wantRepo: "https://example.org/OWNER/REPO", }, + { + name: "PR URL argument", + args: args{ + selector: "https://example.org/OWNER/REPO/pull/13#comment-123", + baseRepoFn: nil, + }, + httpStub: func(r *httpmock.Registry) { + r.Register( + httpmock.GraphQL(`query IssueByNumber\b`), + httpmock.StringResponse(`{"data":{"repository":{ + "hasIssuesEnabled": true, + "issue":{"number":13} + }}}`)) + }, + wantIssue: 13, + wantRepo: "https://example.org/OWNER/REPO", + }, { name: "project cards permission issue", args: args{ From a6cccdf6713412d9d321d6df0a4b8ae9d9084c5e Mon Sep 17 00:00:00 2001 From: t4kamura Date: Mon, 18 Mar 2024 22:49:23 +0900 Subject: [PATCH 2/2] Add pr url pattern --- pkg/cmd/issue/shared/lookup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/issue/shared/lookup.go b/pkg/cmd/issue/shared/lookup.go index 1aa58c951..f93b0867d 100644 --- a/pkg/cmd/issue/shared/lookup.go +++ b/pkg/cmd/issue/shared/lookup.go @@ -100,7 +100,7 @@ func IssuesFromArgsWithFields(httpClient *http.Client, baseRepoFn func() (ghrepo return issues, issuesRepo, nil } -var issueURLRE = regexp.MustCompile(`^/([^/]+)/([^/]+)/issues/(\d+)`) +var issueURLRE = regexp.MustCompile(`^/([^/]+)/([^/]+)/(?:issues|pull)/(\d+)`) func issueMetadataFromURL(s string) (int, ghrepo.Interface) { u, err := url.Parse(s)