-
Notifications
You must be signed in to change notification settings - Fork 53
Added attachment releases data #83
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ type Release struct { | |
// swagger:strfmt date-time | ||
PublishedAt time.Time `json:"published_at"` | ||
Publisher *User `json:"author"` | ||
Attachments []*Attachment `json:"assets"` | ||
} | ||
|
||
// ListReleases list releases of a repository | ||
|
@@ -48,6 +49,33 @@ func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) { | |
return r, err | ||
} | ||
|
||
// ListReleaseAttachments gets all the assets of a release in a repository | ||
func (c *Client) ListReleaseAttachments(user, repo string, id int64) ([]*Attachment, error) { | ||
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. These functions were removed in #77, because the API endpoints they use do not exist. I think we should only bring them back if we have plans to implement the corresponding API endpoints in the near future. 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. Looks like we do have plans: go-gitea/gitea#3075 |
||
attachments := make([]*Attachment, 0, 10) | ||
err := c.getParsedResponse("GET", | ||
fmt.Sprintf("/repos/%s/%s/releases/%d/assets", user, repo, id), | ||
nil, nil, &attachments) | ||
return attachments, err | ||
} | ||
|
||
// GetReleaseAttachment gets a single attachment of a release in a repository | ||
func (c *Client) GetReleaseAttachment(user, repo string, releaseID int64, attachmentID int64) (*Attachment, error) { | ||
attachment := new(Attachment) | ||
err := c.getParsedResponse("GET", | ||
fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, releaseID, attachmentID), | ||
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. This route is incorrect: https://developer.github.com/v3/repos/releases/#get-a-single-release-asset 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. It is incorrect, but the modeling of github is different from what gitea has. 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. I think we could keep 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. @stefan-lacatus AFAIK, an asset is uniquely identified by its id. Although an attachment is associated with a particular issue or release, you do not need which issue or release in order to identify an asset by its id. So, as far as I can tell, supporting the Github-style route should not be a problem. |
||
nil, nil, &attachment) | ||
return attachment, err | ||
} | ||
|
||
// GetLatestRelease gets the latest release in a repository. This cannot be a draft or prerelease | ||
func (c *Client) GetLatestRelease(user, repo string) (*Release, error) { | ||
r := new(Release) | ||
err := c.getParsedResponse("GET", | ||
fmt.Sprintf("/repos/%s/%s/releases/latest", user, repo), | ||
nil, nil, &r) | ||
return r, err | ||
} | ||
|
||
// CreateReleaseOption options when creating a release | ||
type CreateReleaseOption struct { | ||
// required: true | ||
|
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.
I removed this because the field was never populated in API endpoints. Releases that do in fact have attachments had an empty
assets
fields, which I thought was misleading.I think we should only add it back if we have plans to populate it in the near future.
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.
Looks like we do have plans: go-gitea/gitea#3075