Comments (3)
I have some code that does something similar to what you're trying to do that might help:
package main
import (
"github.com/andygrunwald/go-gerrit"
)
func main() {
client, err := gerrit.NewClient("", nil)
if err != nil {
panic(err)
}
changes, _, err := client.Changes.QueryChanges(
&gerrit.QueryChangeOptions{
QueryOptions: gerrit.QueryOptions{
Query: []string{"(is:open OR is:merged) AND after:2016-09-20"}},
ChangeOptions: gerrit.ChangeOptions{
AdditionalFields: []string{
"DETAILED_LABELS",
"DETAILED_ACCOUNTS"}}})
if err != nil {
panic(err)
}
for _, change := range *changes {
for _, label := range change.Labels.CodeReview.All {
...
}
}
}
I think all the info you're looking for is going to be somewhere under the change.Labels.CodeReview
struct. Generally speaking go-gerrit does not really modify the structures returned from Gerrit so if Gerrit's documentation references the info you're looking for then it's usually a matter of either tuning the query or fixing where you look for the data. Failing that I usually try using curl to figure out what I'm missing and to understand the general data structure better.
Let me know if you have more questions of if I've missed something.
from go-gerrit.
I think you are misunderstanding me. The issue is that the information sent back for a "Query Changes" or "Get Change Detail" would normally not contain any information pertaining to approvals, if there are no approvals. In such cases the Json returned looks something like this:
....
"url": "https://lh5.googleusercontent.com/-83BEYip0k-E/AAAAAAAAAAI/AAAAAAAAAAA/rybERPNrtdM/s100-p/photo.jpg",
"height": 100
}
]
},
"labels": {
"Verified": {
"values": {
"-1": "Fails",
" 0": "No score",
"+1": "Verified"
},
"default_value": 0
},
"Code-Review": {
"values": {
"-2": "Do not submit",
"-1": "I would prefer that you didn\u0027t submit this",
" 0": "No score",
"+1": "Looks good to me, but someone else must approve",
"+2": "Looks good to me, approved"
},
"default_value": 0
}
},
"permitted_labels": {
"Code-Review": [
"-1",
" 0",
"+1"
]
},
"removable_reviewers": [],
"reviewers": {},
"reviewer_updates": [],
"messages": [
{
"id": "fc66fb4452cff31b138fbd67e3cef19953679a5b
....
I can see how you have through about this stuff. According to the documentation of the REST API a LabelInfo
record should be returned and this would contain optional AccountInfo
or ApprovalInfo
records. But looking at AccountInfo _account_id
is not set as optional, and therefore there will always be an AccountInfo
returned by your API, even if there wasn't any returned by Gerrit.
So what I am saying is, I think you need to change the _account_id
to be optional so that these fields will turn out to be nothing, if Gerrit didn't return anything. As it stands now, your API is basically saying that account_id 0 (admin?) has done some approvals when in fact they haven't.
And the follow on problem with the current state is that to figure out whether there actually is an approval I have to create an empty AccountInfo
record and compare with that, since two structs with the same values return "equals" in Golang. But I'd rather not carry on like that and get the problem sorted at root cause.
from go-gerrit.
It's all ok from my point of view.
from go-gerrit.
Related Issues (20)
- Update CHANGELOG.md
- Craft a new release HOT 2
- Where to get the revisionID for the GetComment API ? HOT 2
- Projects.SetConfig endpoint fails with 400 Bad Request due to ConfigInput.MaxObjectSizeLimit zero value not being omitted HOT 5
- Contexts HOT 1
- Can't get the library working for repo names containing slashes HOT 1
- `ProjectBaseOptions` improper uri tag for `Skip` field
- API-Methods: Return map/slice directly, rather than a pointer to one
- Proposal: Use Timestamp type for all time fields. HOT 3
- Simpler fix for credentials with characters such as '/'. HOT 2
- Optimize Error-Handling-Code of read body
- Only 500 changes are being pulled HOT 8
- labels should not be pre-escaped HOT 3
- All DELETE api calls returns error 400 (Bad request) HOT 5
- Function DeleteDraftChange should be renamed as DeleteChange HOT 1
- Hello? <crickets> HOT 6
- SetReview support for --project option HOT 2
- Document missing OpenAPI/Swagger-Defintion/API-Spec HOT 2
- Error in Projects.CreateProject: PUT a/projects/{name} invalid JSON in request HOT 6
- Add support for context package HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-gerrit.