-
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 3 commits
752e454
9aba995
f57a237
76cfab3
4550de5
13f260e
14b279b
6fd4bfd
171deba
c5e05bf
1d84d92
a3c6983
45fb09c
1e86822
0000b64
d261d4f
f4e9158
394a89c
23de54e
8f1e865
f4515f7
f207870
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) { | ||
|
tommaso-moro marked this conversation as resolved.
Outdated
tommaso-moro marked this conversation as resolved.
Outdated
|
||
| 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) { | ||
|
tommaso-moro marked this conversation as resolved.
Outdated
|
||
| 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) { | ||
|
tommaso-moro marked this conversation as resolved.
Outdated
|
||
| 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) { | ||
|
tommaso-moro marked this conversation as resolved.
Outdated
|
||
| 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 | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.