From a297625ae43f70d546082da5700e8a01f7004fce Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 17 Nov 2020 16:31:06 +0100 Subject: [PATCH 1/3] add HTMLURL --- gitea/issue.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gitea/issue.go b/gitea/issue.go index 7eef447..bf07438 100644 --- a/gitea/issue.go +++ b/gitea/issue.go @@ -32,6 +32,7 @@ type RepositoryMeta struct { type Issue struct { ID int64 `json:"id"` URL string `json:"url"` + HTMLURL string `json:"html_url"` Index int64 `json:"number"` Poster *User `json:"user"` OriginalAuthor string `json:"original_author"` -- 2.40.1 From 643ff473c248e7b6d5b2375ed0363073beec6c5b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 17 Nov 2020 16:31:25 +0100 Subject: [PATCH 2/3] deprecate Assignee --- gitea/issue.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gitea/issue.go b/gitea/issue.go index bf07438..97e749a 100644 --- a/gitea/issue.go +++ b/gitea/issue.go @@ -41,8 +41,10 @@ type Issue struct { Body string `json:"body"` Labels []*Label `json:"labels"` Milestone *Milestone `json:"milestone"` - Assignee *User `json:"assignee"` - Assignees []*User `json:"assignees"` + // deprecated + // TODO: rm on sdk 0.15.0 + Assignee *User `json:"assignee"` + Assignees []*User `json:"assignees"` // Whether the issue is open or closed State StateType `json:"state"` IsLocked bool `json:"is_locked"` -- 2.40.1 From 43e83038f2ae077110e7567c506ca6e6049c9aea Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 17 Nov 2020 16:45:04 +0100 Subject: [PATCH 3/3] add backwards compatibility --- gitea/issue.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gitea/issue.go b/gitea/issue.go index 97e749a..0b0824f 100644 --- a/gitea/issue.go +++ b/gitea/issue.go @@ -131,6 +131,9 @@ func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, *Response, error) { } } } + for i := range issues { + c.issueBackwardsCompatibility(issues[i]) + } return issues, resp, err } @@ -149,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 } @@ -159,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 { issue.Repository.Owner = strings.Split(issue.Repository.FullName, "/")[0] } + c.issueBackwardsCompatibility(issue) return issue, resp, err } @@ -197,6 +204,7 @@ func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, issue := new(Issue) resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues", owner, repo), jsonHeader, bytes.NewReader(body), issue) + c.issueBackwardsCompatibility(issue) return issue, resp, err } @@ -232,5 +240,12 @@ func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption) resp, err := c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), jsonHeader, bytes.NewReader(body), issue) + c.issueBackwardsCompatibility(issue) 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) + } +} -- 2.40.1