Merge pull request #8837 from t4kamura/fix-cannot-lock-pr-url

Fixed `gh pr lock/unlock` not working when URL is passed
This commit is contained in:
Andy Feller 2024-04-05 08:29:35 -04:00 committed by GitHub
commit 0a2ede0279
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -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)

View file

@ -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{