Update Issue Struct (#458)
add HTMLURL deprecate Assignee add backwards compatibility Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/458 Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-Authored-By: 6543 <6543@obermui.de> Co-Committed-By: 6543 <6543@obermui.de>
This commit is contained in:
parent
60293eb2d1
commit
6ea6e887f2
1 changed files with 20 additions and 2 deletions
|
@ -32,6 +32,7 @@ type RepositoryMeta struct {
|
||||||
type Issue struct {
|
type Issue struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
|
HTMLURL string `json:"html_url"`
|
||||||
Index int64 `json:"number"`
|
Index int64 `json:"number"`
|
||||||
Poster *User `json:"user"`
|
Poster *User `json:"user"`
|
||||||
OriginalAuthor string `json:"original_author"`
|
OriginalAuthor string `json:"original_author"`
|
||||||
|
@ -40,8 +41,10 @@ type Issue struct {
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
Labels []*Label `json:"labels"`
|
Labels []*Label `json:"labels"`
|
||||||
Milestone *Milestone `json:"milestone"`
|
Milestone *Milestone `json:"milestone"`
|
||||||
Assignee *User `json:"assignee"`
|
// deprecated
|
||||||
Assignees []*User `json:"assignees"`
|
// TODO: rm on sdk 0.15.0
|
||||||
|
Assignee *User `json:"assignee"`
|
||||||
|
Assignees []*User `json:"assignees"`
|
||||||
// Whether the issue is open or closed
|
// Whether the issue is open or closed
|
||||||
State StateType `json:"state"`
|
State StateType `json:"state"`
|
||||||
IsLocked bool `json:"is_locked"`
|
IsLocked bool `json:"is_locked"`
|
||||||
|
@ -128,6 +131,9 @@ func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, *Response, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for i := range issues {
|
||||||
|
c.issueBackwardsCompatibility(issues[i])
|
||||||
|
}
|
||||||
return issues, resp, err
|
return issues, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +152,9 @@ func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Iss
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for i := range issues {
|
||||||
|
c.issueBackwardsCompatibility(issues[i])
|
||||||
|
}
|
||||||
return issues, resp, err
|
return issues, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +165,7 @@ func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, *Response, e
|
||||||
if e := c.checkServerVersionGreaterThanOrEqual(version1_12_0); e != nil && issue.Repository != nil {
|
if e := c.checkServerVersionGreaterThanOrEqual(version1_12_0); e != nil && issue.Repository != nil {
|
||||||
issue.Repository.Owner = strings.Split(issue.Repository.FullName, "/")[0]
|
issue.Repository.Owner = strings.Split(issue.Repository.FullName, "/")[0]
|
||||||
}
|
}
|
||||||
|
c.issueBackwardsCompatibility(issue)
|
||||||
return issue, resp, err
|
return issue, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +204,7 @@ func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue,
|
||||||
issue := new(Issue)
|
issue := new(Issue)
|
||||||
resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues", owner, repo),
|
resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues", owner, repo),
|
||||||
jsonHeader, bytes.NewReader(body), issue)
|
jsonHeader, bytes.NewReader(body), issue)
|
||||||
|
c.issueBackwardsCompatibility(issue)
|
||||||
return issue, resp, err
|
return issue, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,5 +240,12 @@ func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption)
|
||||||
resp, err := c.getParsedResponse("PATCH",
|
resp, err := c.getParsedResponse("PATCH",
|
||||||
fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index),
|
fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index),
|
||||||
jsonHeader, bytes.NewReader(body), issue)
|
jsonHeader, bytes.NewReader(body), issue)
|
||||||
|
c.issueBackwardsCompatibility(issue)
|
||||||
return issue, resp, err
|
return issue, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) issueBackwardsCompatibility(issue *Issue) {
|
||||||
|
if c.checkServerVersionGreaterThanOrEqual(version1_12_0) != nil {
|
||||||
|
issue.HTMLURL = fmt.Sprintf("%s/%s/issues/%d", c.url, issue.Repository.FullName, issue.Index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue