IssueOrPullRequestID returns the ID of the issue or pull request from a URL.
(rawURL string)
| 1296 | |
| 1297 | // IssueOrPullRequestID returns the ID of the issue or pull request from a URL. |
| 1298 | func (c *Client) IssueOrPullRequestID(rawURL string) (string, error) { |
| 1299 | uri, err := url.Parse(rawURL) |
| 1300 | if err != nil { |
| 1301 | return "", err |
| 1302 | } |
| 1303 | variables := map[string]any{ |
| 1304 | "url": githubv4.URI{URL: uri}, |
| 1305 | } |
| 1306 | var query issueOrPullRequest |
| 1307 | err = c.doQueryWithProgressIndicator("GetIssueOrPullRequest", &query, variables) |
| 1308 | if err != nil { |
| 1309 | return "", err |
| 1310 | } |
| 1311 | if query.Resource.Typename == "Issue" { |
| 1312 | return query.Resource.Issue.ID, nil |
| 1313 | } else if query.Resource.Typename == "PullRequest" { |
| 1314 | return query.Resource.PullRequest.ID, nil |
| 1315 | } |
| 1316 | return "", errors.New("resource not found, please check the URL") |
| 1317 | } |
| 1318 | |
| 1319 | // userProjects queries the $first projects of a user. |
| 1320 | type userProjects struct { |
no test coverage detected