-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: Add Issue Dependencies API support #4130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,110 @@ | ||||||
| // Copyright 2026 The go-github AUTHORS. All rights reserved. | ||||||
| // | ||||||
| // Use of this source code is governed by a BSD-style | ||||||
| // license that can be found in the LICENSE file. | ||||||
|
|
||||||
| package github | ||||||
|
|
||||||
| import ( | ||||||
| "context" | ||||||
| "fmt" | ||||||
| ) | ||||||
|
|
||||||
| // IssueDependencyRequest represents a request to add a dependency to an issue. | ||||||
| type IssueDependencyRequest struct { | ||||||
| IssueID *int64 `json:"issue_id,omitempty"` | ||||||
| } | ||||||
|
|
||||||
| // ListBlockedBy lists the dependencies that block the specified issue. | ||||||
| // | ||||||
| // GitHub API docs: https://docs.github.com/rest/issues/issue-dependencies#list-dependencies-an-issue-is-blocked-by | ||||||
| // | ||||||
| //meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by | ||||||
| func (s *IssuesService) ListBlockedBy(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Issue, *Response, error) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
"issue_dependencies_summary": {
"title": "Issue Dependencies Summary",
"type": "object",
"properties": {
"blocked_by": {
"type": "integer"
},
"blocking": {
"type": "integer"
},
"total_blocked_by": {
"type": "integer"
},
"total_blocking": {
"type": "integer"
}
},
"required": [
"blocked_by",
"blocking",
"total_blocked_by",
"total_blocking"
]
}Additionally, several other fields are missing, such as can you add these to |
||||||
| u := fmt.Sprintf("repos/%v/%v/issues/%v/dependencies/blocked_by", owner, repo, number) | ||||||
| u, err := addOptions(u, opts) | ||||||
| if err != nil { | ||||||
| return nil, nil, err | ||||||
| } | ||||||
|
|
||||||
| req, err := s.client.NewRequest("GET", u, nil) | ||||||
| if err != nil { | ||||||
| return nil, nil, err | ||||||
| } | ||||||
|
|
||||||
| var issues []*Issue | ||||||
| resp, err := s.client.Do(ctx, req, &issues) | ||||||
| if err != nil { | ||||||
| return nil, resp, err | ||||||
| } | ||||||
|
|
||||||
| return issues, resp, nil | ||||||
| } | ||||||
|
|
||||||
| // AddBlockedBy adds a "blocked by" dependency to the specified issue. | ||||||
| // | ||||||
| // GitHub API docs: https://docs.github.com/rest/issues/issue-dependencies#add-a-dependency-an-issue-is-blocked-by | ||||||
| // | ||||||
| //meta:operation POST /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by | ||||||
| func (s *IssuesService) AddBlockedBy(ctx context.Context, owner, repo string, number int, issueDepReq *IssueDependencyRequest) (*Issue, *Response, error) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. body is required so should we pass it by value?
Suggested change
|
||||||
| u := fmt.Sprintf("repos/%v/%v/issues/%v/dependencies/blocked_by", owner, repo, number) | ||||||
| req, err := s.client.NewRequest("POST", u, issueDepReq) | ||||||
| if err != nil { | ||||||
| return nil, nil, err | ||||||
| } | ||||||
|
|
||||||
| var issue *Issue | ||||||
| resp, err := s.client.Do(ctx, req, &issue) | ||||||
| if err != nil { | ||||||
| return nil, resp, err | ||||||
| } | ||||||
|
|
||||||
| return issue, resp, nil | ||||||
| } | ||||||
|
|
||||||
| // RemoveBlockedBy removes a "blocked by" dependency from the specified issue. | ||||||
| // | ||||||
| // GitHub API docs: https://docs.github.com/rest/issues/issue-dependencies#remove-dependency-an-issue-is-blocked-by | ||||||
| // | ||||||
| //meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by/{issue_id} | ||||||
| func (s *IssuesService) RemoveBlockedBy(ctx context.Context, owner, repo string, number int, issueID int64) (*Issue, *Response, error) { | ||||||
| u := fmt.Sprintf("repos/%v/%v/issues/%v/dependencies/blocked_by/%v", owner, repo, number, issueID) | ||||||
| req, err := s.client.NewRequest("DELETE", u, nil) | ||||||
| if err != nil { | ||||||
| return nil, nil, err | ||||||
| } | ||||||
|
|
||||||
| var issue *Issue | ||||||
| resp, err := s.client.Do(ctx, req, &issue) | ||||||
| if err != nil { | ||||||
| return nil, resp, err | ||||||
| } | ||||||
|
|
||||||
| return issue, resp, nil | ||||||
| } | ||||||
|
|
||||||
| // ListBlocking lists the issues that the specified issue is blocking. | ||||||
| // | ||||||
| // GitHub API docs: https://docs.github.com/rest/issues/issue-dependencies#list-dependencies-an-issue-is-blocking | ||||||
| // | ||||||
| //meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocking | ||||||
| func (s *IssuesService) ListBlocking(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Issue, *Response, error) { | ||||||
| u := fmt.Sprintf("repos/%v/%v/issues/%v/dependencies/blocking", owner, repo, number) | ||||||
| u, err := addOptions(u, opts) | ||||||
| if err != nil { | ||||||
| return nil, nil, err | ||||||
| } | ||||||
|
|
||||||
| req, err := s.client.NewRequest("GET", u, nil) | ||||||
| if err != nil { | ||||||
| return nil, nil, err | ||||||
| } | ||||||
|
|
||||||
| var issues []*Issue | ||||||
| resp, err := s.client.Do(ctx, req, &issues) | ||||||
| if err != nil { | ||||||
| return nil, resp, err | ||||||
| } | ||||||
|
|
||||||
| return issues, resp, nil | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove
omitemptysince it is a required parameter?