-
Notifications
You must be signed in to change notification settings - Fork 53
Added read-only attachments to the Releases API #63
Conversation
List assets: GET /repos/:owner/:repo/releases/:id/assets Get single asset: GET /repos/:owner/:repo/releases/assets/:id
gitea/attachment.go
Outdated
import "time" | ||
|
||
// a generic attachment | ||
type Attachment struct { |
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.
At least in SDK I think we should call it also as Asset
so that there would not be different names for same thing.
Also type comment must start with type name like // Asset represents a release attachments
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.
But because the Attachments can be used in multiple places (releases, issues, comments) is it worth to make this change? Or should we rename Attachements to assets everywhere? Having two words for the same thing is confusing.
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.
Yes but attachments for issues and comments most probably wont have same structure anyway (in API).
gitea/release.go
Outdated
} | ||
|
||
// GetReleaseAsset gets all the assets of a release in a repository | ||
func (c *Client) GetReleaseAsset(user, repo string, releaseId int64, assetId int64) (*Release, error) { |
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.
releaseId must be called releaseID, assetId -> assetID
Run make lint
to check if your golang code validates against GoLang naming convention
…s the latest published full release for the repository. Draft releases and prereleases are not returned by this endpoint. Signed-off-by: Petrisor Lacatus <[email protected]>
Signed-off-by: Petrisor Lacatus <[email protected]>
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.
#namingthings
gitea/release.go
Outdated
@@ -46,6 +47,33 @@ func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) { | |||
return r, err | |||
} | |||
|
|||
// ListReleaseAssets gets all the assets of a release in a repository | |||
func (c *Client) ListReleaseAssets(user, repo string, id int64) (*Release, error) { |
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.
These should be be named Attachments
instead of Assets
since Gitea calls them that :)
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.
@bkcsoft but in GitHub api they are called assets and we want API to be compatible with GitHub
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.
Indeed, but the function should still be called Attachment, even though the payload has Assets :)
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.
Ok, so everywhere in the code we still refer to them as Attachments, and the only place where "asset" appears is in the json for the release?
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.
@bkcsoft I think it will be confusing that endpoints and in json it is called assets but in sdk attachments
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.
So, how should I name things? A decision has to be reached by you guys...
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.
@stefan-lacatus after talking to @bkcsoft we agreed on naming that in golang code we should use name Attachment
and in json payloads and url's use GitHub name asset
The only place we refer to attachments as assets is in the api json response Signed-off-by: Petrisor Lacatus <[email protected]>
I've changed the naming as suggested. Now we refer to release attachments as Attachments everywhere in the code, except in the JSON response where they are called assets and in the endpoint names |
gitea/release.go
Outdated
@@ -46,6 +47,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) (*Release, error) { |
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.
This should return a []*Attachment
, not *Release
https://developer.github.com/v3/repos/releases/#list-assets-for-a-release
gitea/release.go
Outdated
} | ||
|
||
// GetReleaseAttachment gets all the assets of a release in a repository | ||
func (c *Client) GetReleaseAttachment(user, repo string, releaseID int64, attachmentID int64) (*Release, error) { |
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.
Same here, []*Attachment
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.
Here it should have been a *Attachment
since we are only returning one instance. I've also updated the function description as it was incorrect
Updated method description Signed-off-by: Petrisor Lacatus <[email protected]>
@lafriks mind reviewing again? 🙂 |
LGTM |
LGTM as well :) |
I think we should wait for 1.2.0 to be released before we merge this |
|
I think that this PR could be closed becuase the #90 already implemented this feature. |
Added a assets array to the releases GET request. This is a required change for go-gitea/gitea#2084
GET /repos/:owner/:repo/releases[/:id]
- now includes assetsGET /repos/:owner/:repo/releases/:id/assets
GET /repos/:owner/:repo/releases/assets/:id