You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add more options to branch.protect() function #1355
I've tried this alternative approach now (project.protectedbranches.create()), and it doesn't seem to work as intended - nothing updated in the UI and it appeared as if I could still push (albeit that part is a little bit trickier to confirm as I don't know the intention behind the 60 status level; me being owner of the repo might still qualify here).
that it expects a list as argument (seems unlikely due to the examples in the documentation)
that I typed in some minor error somewhere; but what's odd then is that everything seemed to work on the CLI-side (project.protectedbranches.list() showed that I had created new entries).
Either way, there doesn't seem to be any reason to keep this issue open any longer. Thank you for the help!
Activity
JohnVillalovos commentedon Mar 2, 2021
Have you looked at:
https://python-gitlab.readthedocs.io/en/stable/gl_objects/protected_branches.html
JohnVillalovos commentedon Mar 2, 2021
Interestingly it looks like the code is calling an undocumented API. Maybe it was previously documented.
https://docs.gitlab.com/ce/api/branches.html
python-gitlab/gitlab/v4/objects/branches.py
Lines 21 to 43 in 96d2805
JohnVillalovos commentedon Mar 3, 2021
It appears that branch.protect() was likely a v3 API thing. I'm guessing v4 still supports it but it is undocumented. I have not personally tried it.
https://gitlab.com/gitlab-org/gitlab-foss/-/blob/8-16-stable/doc/api/branches.md
anderslindho commentedon Mar 3, 2021
I had not seen the first link you provided - I will try out that approach.
I have tried the
branch.protect()function and can verifiy that it at least works with v4.anderslindho commentedon Mar 3, 2021
I've tried this alternative approach now (
project.protectedbranches.create()), and it doesn't seem to work as intended - nothing updated in the UI and it appeared as if I could still push (albeit that part is a little bit trickier to confirm as I don't know the intention behind the60status level; me being owner of the repo might still qualify here).JohnVillalovos commentedon Mar 3, 2021
Might be something like this:
In the UI I then see that "No one" is allowed to push.
I was also unable to do a
git pushto that branch.anderslindho commentedon Mar 3, 2021
That worked brilliantly - thank you very much! 🙏
So my mistake was either:
project.protectedbranches.list()showed that I had created new entries).Either way, there doesn't seem to be any reason to keep this issue open any longer. Thank you for the help!