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