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 'squash_option (never, always, default_on, default_off)' in projects #1744
Description of the problem, including code/CLI snippet
The "squash_option" gitlab project setting is not available in python object project like other merge options.
Expected Behavior
project = gitlab.projects.get(id)
print('\tMerge method:', project.merge_method)
print('\tRemove source branch after merge:', project.remove_source_branch_after_merge)
print('\tSquash commit when merging:', project.squash_option)
print('\tOnly allow merge if pipeline secceeds:', project.only_allow_merge_if_pipeline_succeeds)
print('\tOnly allow merge if all discussions are resolved:', project.only_allow_merge_if_all_discussions_are_resolved)
Actual Behavior
project = gitlab.projects.get(id)
print('\tMerge method:', project.merge_method)
print('\tRemove source branch after merge:', project.remove_source_branch_after_merge)
print('\tSquash commit when merging:', '???')
print('\tOnly allow merge if pipeline secceeds:', project.only_allow_merge_if_pipeline_succeeds)
print('\tOnly allow merge if all discussions are resolved:', project.only_allow_merge_if_all_discussions_are_resolved)
Specifications
python-gitlab version: 2.10.1
API version you are using (v3/v4): v4
Gitlab server version (or gitlab.com): gitlab enterprise edition 13.11.1
Traceback (most recent call last):
File "...\AppData\Local\Programs\Python\Python39\lib\site-packages\gitlab\base.py", line 85, in __getattr__
return self.__dict__["_updated_attrs"][name]
KeyError: 'squash_option'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "...\AppData\Local\Programs\Python\Python39\lib\site-packages\gitlab\base.py", line 88, in __getattr__
value = self.__dict__["_attrs"][name]
KeyError: 'squash_option'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "...\AppData\Local\Programs\Python\Python39\lib\site-packages\gitlab\base.py", line 108, in __getattr__
return self.__dict__["_parent_attrs"][name]
KeyError: 'squash_option'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "....py", line 38, in <module>
print('\tSquash commit when merging:', project.squash_option)
File "...\AppData\Local\Programs\Python\Python39\lib\site-packages\gitlab\base.py", line 110, in __getattr__
raise AttributeError(name)
AttributeError: squash_option
Activity
JohnVillalovos commentedon Dec 13, 2021
What kind of error do you get when you try to access
project.squash_options?svart-riddare commentedon Dec 13, 2021
Simply that the attribute does not exist :
JohnVillalovos commentedon Dec 13, 2021
Have you tested this against https://gitlab.com ?
I just did it and it worked. My theory is that your version of Gitlab is too old.
Search for the string
squash_optionhere:https://gitlab.com/gitlab-org/gitlab/-/blob/master/CHANGELOG.md
It appears it was added in Gitlab 14.1.0.
JohnVillalovos commentedon Dec 13, 2021
Though we still need to add it to the list of known attributes so it can be used in the CLI.
svart-riddare commentedon Dec 13, 2021
You are right, I have this option in the gitlab GUI but it was added in the Gitlab API in 14.1.0 as you pointed out. Thank you for your time !
Add support for `squash_option` in Projects
feat: add support for `squash_option` in Projects