Closed MUlt1mate closed 1 year ago
Looking at the examples this should indeed be a call the uses the request body to send the data instead of query params. Wonder if we need to add PATH to this line https://github.com/xanzy/go-gitlab/blob/master/gitlab.go#L579
I don't see anything re a permission ID in the examples... Care to share what you mean?
I mean this: https://docs.gitlab.com/ee/api/protected_branches.html#example-update-a-push_access_level-record
'{"allowed_to_push": [{"id": 12, "access_level": 0}]'
What's our next steps?
Is there any news on this issue, I can confirm that even on v0.81.0 this issue occurs, the only viable bypass would be to recreate the protected branch object, which is very inconvenient as requires an update to the approval rules (if attached directly to such branch) every time.
Work is being done in PR #1680 to fix this one...
For folks that don't want to modify the library there is a workaround that I've tested for managing push and merge rules on protected branches. Code to destroy an access level:
var aas = []accessstub{
{
Destroy: true,
ID: pal.ID,
},
}
var pupp = &updatePushProtection{
AllowedToPush: aas,
}
ret_req, err := git.NewRequest("PATCH", path, pupp, nil)
mpupp, _ := json.Marshal(pupp)
ret_req.Header.Set("Content-Type", "application/json")
ret_req.SetBody(mpupp)
_, err = git.Do(ret_req, nil)
Hey there. I'm using v0.80.1 I think UpdateProtectedBranch method is broken.
I call it and I get an error
SetMergePermissions error PATCH: 400 {error: allowed_to_push is invalid, allowed_to_merge is invalid}
RawQuery for the request is
allowed_to_merge={<nil> <nil> <nil> 0xc0003f24d0}&allowed_to_push={<nil> <nil> <nil> 0xc0003f24d8}
I've tried to override NewRequest and send the payload in the body, but marshaling result was
<unsupported type: []uint8>
Also, as far as I understood from docs, you have to send permission ID in the request. But BranchPermissionOptions struct lacks the field.