Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load label ID in NewLabels #2045

Merged
merged 1 commit into from
Jun 25, 2017
Merged

Conversation

ethantkoenig
Copy link
Member

@ethantkoenig ethantkoenig commented Jun 23, 2017

Fix bug in NewLabels(..) where the ID field for the labels were not populated. This caused a problem in the POST /repos/:user/:repo/labels API endpoint, where the response label would have an "id" attribute of 0.

Also update the unit test to check that ID has been populated.

@@ -98,7 +98,11 @@ func (label *Label) ForegroundColor() template.CSS {

// NewLabels creates new label(s) for a repository.
func NewLabels(labels ...*Label) error {
_, err := x.Insert(labels)
Copy link
Member

Choose a reason for hiding this comment

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

why not just x.Insert(labels...)?

Copy link
Member

Choose a reason for hiding this comment

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

And of course, a transaction is needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

x.Insert(labels...) doesn't compile, since labels is of type []*Label, and the argument to x.Insert(..) has to be of type []interface{}.

I don't understand why is a transaction needed? From what I can tell, the call to x.Insert(..)will just generate one INSERT command.

Copy link
Member

Choose a reason for hiding this comment

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

x.Insert(slice) is one INSERT command, x.Insert(slice...) will generate N INSERT command. A transaction for a better performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I see. Updated to use a transaction.

@lunny lunny added the type/bug label Jun 24, 2017
@lunny lunny added this to the 1.2.0 milestone Jun 24, 2017
@lafriks
Copy link
Member

lafriks commented Jun 24, 2017

LGTM

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Jun 24, 2017
@ethantkoenig
Copy link
Member Author

Rebased to run CI again

@lunny
Copy link
Member

lunny commented Jun 25, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 25, 2017
@lunny lunny merged commit 2559a34 into go-gitea:master Jun 25, 2017
@ethantkoenig ethantkoenig deleted the fix/new_labels branch June 26, 2017 14:54
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants