1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

gitlab_project: Add initialize_with_readme option (#3601)

* Add initialize_with_readme option to gitlab_project. Update integration/unit tests.

* Fix pep8

* Revert unit tests

* Update plugins/modules/source_control/gitlab/gitlab_project.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/source_control/gitlab/gitlab_project.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/source_control/gitlab/gitlab_project.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Move initialize_with_readme to proper spot to only add if project does not exist.

* Update plugins/modules/source_control/gitlab/gitlab_project.py

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Mikhail Yohman 2021-10-30 00:14:30 -06:00 committed by GitHub
parent 40ccd1501b
commit 9fb76efde0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -48,6 +48,13 @@ options:
description:
- An description for the project.
type: str
initialize_with_readme:
description:
- Will initialize the project with a default C(README.md).
- Is only used when the project is created, and ignored otherwise.
type: bool
default: false
version_added: "4.0.0"
issues_enabled:
description:
- Whether you want to create issues or not.
@ -187,6 +194,7 @@ EXAMPLES = r'''
wiki_enabled: True
snippets_enabled: True
import_url: http://git.example.com/example/lab.git
initialize_with_readme: true
state: present
delegate_to: localhost
'''
@ -270,6 +278,8 @@ class GitLabProject(object):
'path': options['path'],
'import_url': options['import_url'],
})
if options['initialize_with_readme']:
project_options['initialize_with_readme'] = options['initialize_with_readme']
project_options = self.getOptionsWithValue(project_options)
project = self.createProject(namespace, project_options)
changed = True
@ -359,6 +369,7 @@ def main():
name=dict(type='str', required=True),
path=dict(type='str'),
description=dict(type='str'),
initialize_with_readme=dict(type='bool', default=False),
issues_enabled=dict(type='bool', default=True),
merge_requests_enabled=dict(type='bool', default=True),
merge_method=dict(type='str', default='merge', choices=["merge", "rebase_merge", "ff"]),
@ -399,6 +410,7 @@ def main():
project_name = module.params['name']
project_path = module.params['path']
project_description = module.params['description']
initialize_with_readme = module.params['initialize_with_readme']
issues_enabled = module.params['issues_enabled']
merge_requests_enabled = module.params['merge_requests_enabled']
merge_method = module.params['merge_method']
@ -467,6 +479,7 @@ def main():
if gitlab_project.createOrUpdateProject(project_name, namespace, {
"path": project_path,
"description": project_description,
"initialize_with_readme": initialize_with_readme,
"issues_enabled": issues_enabled,
"merge_requests_enabled": merge_requests_enabled,
"merge_method": merge_method,

View file

@ -22,10 +22,10 @@
validate_certs: False
login_token: "{{ gitlab_login_token }}"
name: "{{ gitlab_project_name }}"
initialize_with_readme: True
state: present
register: gitlab_project_state
- assert:
that:
- gitlab_project_state is changed
@ -39,7 +39,6 @@
state: present
register: gitlab_project_state_again
- assert:
that:
- gitlab_project_state_again is not changed