Closed underside closed 5 months ago
According to the docs this needs to be a string with the value yes
or no
. So while a bit weird, this is actually inline with the docs and the GitLab API:
Sorry, maybe I'm a bit annoying :-) But I think it's an error in Gitlab docs
I tested it a bit:
func main() {
envVars := getEnvVars()
git := createGitlabClient(envVars["gitlabToken"])
state := "opened"
opts := &gitlab.ListProjectMergeRequestsOptions{
State: &state,
}
projectID := 950
mergeRequests, _, err := git.MergeRequests.ListProjectMergeRequests(projectID, opts)
if err != nil {
log.Fatal(err)
}
log.Printf(
"MergeRequests found: %d, project ID: %d",
len(mergeRequests),
projectID)
for _, mr := range mergeRequests {
// log.Print(mr)
log.Printf("WIP TYPE: %v", reflect.TypeOf(mr.WorkInProgress))
log.Print("-----")
}
}
And I got a resp:
2024/04/26 11:20:21 WIP TYPE: bool
I'm not sure maybe I should somehow adressed this issue to Gitlab docs, but I have no idea how to do it :-)
I have the feeling you are mixing 2 up different things here.
Your link goes to an option struct which has a field called WIP
which is a *string
. This matches the docs (the API expects a string, as shown in the screenshot of the docs).
The test you just showed me here is testing a field called WorkInProgress
which comes from a result struct: https://github.com/xanzy/go-gitlab/blob/main/merge_requests.go#L60
So these are two different fields from two different structs. While related to the same API, one is used for making the request and one is used for parsing the result. So I still don't see what isn't working as expected here.
Oh, you are right Sorry :-)
No worries... 👍🏻
Hi, As far as I understand there is wrong field type here
According to requested json it should be *bool type.
I would like to fix it and create MR, but I'm not very familiar with pull request process.