Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Added read-only attachments to the Releases API #63

Merged
merged 7 commits into from
Aug 23, 2017
Merged

Added read-only attachments to the Releases API #63

merged 7 commits into from
Aug 23, 2017

Conversation

stefan-lacatus
Copy link

Added a assets array to the releases GET request. This is a required change for go-gitea/gitea#2084

  • Get releases GET /repos/:owner/:repo/releases[/:id] - now includes assets
  • List assets: GET /repos/:owner/:repo/releases/:id/assets
  • Get single asset: GET /repos/:owner/:repo/releases/assets/:id

List assets: GET /repos/:owner/:repo/releases/:id/assets
Get single asset: GET /repos/:owner/:repo/releases/assets/:id
import "time"

// a generic attachment
type Attachment struct {
Copy link
Member

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

Copy link
Author

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.

Copy link
Member

@lafriks lafriks Jun 30, 2017

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) {
Copy link
Member

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]>
Copy link
Member

@bkcsoft bkcsoft left a 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) {
Copy link
Member

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 :)

Copy link
Member

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

Copy link
Member

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 :)

Copy link
Author

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?

Copy link
Member

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

Copy link
Author

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...

Copy link
Member

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]>
@stefan-lacatus
Copy link
Author

stefan-lacatus commented Jul 3, 2017

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) {
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, []*Attachment

Copy link
Author

@stefan-lacatus stefan-lacatus Jul 4, 2017

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]>
@bkcsoft
Copy link
Member

bkcsoft commented Jul 4, 2017

@lafriks mind reviewing again? 🙂

@lafriks
Copy link
Member

lafriks commented Jul 8, 2017

LGTM

@bkcsoft
Copy link
Member

bkcsoft commented Jul 9, 2017

LGTM as well :)

@lafriks
Copy link
Member

lafriks commented Jul 12, 2017

I think we should wait for 1.2.0 to be released before we merge this

@bkcsoft
Copy link
Member

bkcsoft commented Aug 23, 2017

stable/v1.2 has been branched so I'm merging this 🙂

@bkcsoft bkcsoft merged commit 11e0aa8 into go-gitea:master Aug 23, 2017
@jonasfranz
Copy link
Member

I think that this PR could be closed becuase the #90 already implemented this feature.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants