Repository: python-gitlab/python-gitlab

Issue:
Add 'squash_option (never, always, default_on, default_off)' in projects
## 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



Discussion:
What kind of error do you get when you try to access `project.squash_options` ?
Simply that the attribute does not exist :

```
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
```

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_option` here:

https://gitlab.com/gitlab-org/gitlab/-/blob/master/CHANGELOG.md

It appears it was added in Gitlab 14.1.0.
Though we still need to add it to the list of known attributes so it can be used in the CLI.
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 !

Resolving patch:
diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py
--- a/gitlab/v4/objects/projects.py
+++ b/gitlab/v4/objects/projects.py
@@ -692,6 +692,7 @@ class ProjectManager(CRUDMixin, RESTManager):
             "show_default_award_emojis",
             "snippets_access_level",
             "snippets_enabled",
+            "squash_option",
             "tag_list",
             "template_name",
             "template_project_id",
@@ -760,6 +761,7 @@ class ProjectManager(CRUDMixin, RESTManager):
             "show_default_award_emojis",
             "snippets_access_level",
             "snippets_enabled",
+            "squash_option",
             "suggestion_commit_message",
             "tag_list",
             "visibility",
diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py
--- a/gitlab/v4/objects/users.py
+++ b/gitlab/v4/objects/users.py
@@ -500,6 +500,7 @@ class UserProjectManager(ListMixin, CreateMixin, RESTManager):
             "merge_requests_enabled",
             "wiki_enabled",
             "snippets_enabled",
+            "squash_option",
             "public",
             "visibility",
             "description",


Test patch: