- Notifications
You must be signed in to change notification settings - Fork673
project creation ignores default_branch and default-branch contradicts documentation#3182
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Description of the problem, including code/CLI snippetI've spent a couple hours on this, but basically when creating a project from the python package or from CLI, the
The same thing happens from CLI:
Expected BehaviorAfter creation as described, the project object should show Regardless of being created from CLI or SDK. Actual BehaviorThe CLI and SDK both show that the default branch is "main". The console says that a default branch cannot be set on an empty repo. If this is not possible because of how the gitlab package is a thin wrapper over gitlab REST API, the readme in this repo should at least mention such discrepencies between the docs (auto generated from the REST API, shown in the CLI --help output) and actual behavior. Workaround (possibly a hack)Call these 2 functions, in order:
After running these 2, the git repo will have only master branch, and gitlab console will show this and that it is default and protected, Specifications
|
BetaWas this translation helpful?Give feedback.
All reactions
Maybe try withinitialize_with_readme
?
Replies: 3 comments 5 replies
-
Maybe try with |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@JohnVillalovos thanks that's interesting. Led me to this:#2869 (comment), and in particular
I'm thinking that could be the cause here, since the gitlab account is part of an organization where there could be such rules in place, is there a way that I can verify whether that's the case? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Sorry, I don't know off the top of my head, besides asking your administrator. As a note, always good to look at the upstream docs. I found the I don't believe this is a bug/issue with python-gitlab, but a bug/issue with how GitLab works. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Just saw your answer here. Indeed. That's good to know about the upstream docs. Due to lack of familiarity with how the gitlab package is constructed, I did not think of looking there. I think a short blurb onhttps://python-gitlab.readthedocs.io/en/stable/api-usage.html# explaining that these docs should be used in conjunction withhttps://docs.gitlab.com/api/api_resources/ could save new users some time and pain. |
BetaWas this translation helpful?Give feedback.
All reactions
-
So adding However I still think it would be useful to make this more obvious. I searched the web and all the hits I find, nothing indicates that Also I guess this should be converted back to an issue? |
BetaWas this translation helpful?Give feedback.
All reactions
-
A pull request would be welcome if would like to do it. Glad to hear it worked for you. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Just saw your other answer about the API docs, so how about this instead: I'll create a PR to edit the pagehttps://python-gitlab.readthedocs.io/en/stable/api-usage.html#, adding an explanation that python docs should be used in conjunction withhttps://docs.gitlab.com/api/api_resources/. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Sounds good. I thought there was already something there but if so it sounds like it isn't prominent enough. |
BetaWas this translation helpful?Give feedback.
All reactions
This discussion was converted from issue #3181 on April 26, 2025 20:41.