Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitlab_hook: minor refactoring #5271

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/5271-gitlab_hook-refactor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- gitlab_hook - minor refactoring (https://github.com/ansible-collections/community.general/pull/5271).
17 changes: 7 additions & 10 deletions plugins/modules/source_control/gitlab/gitlab_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,8 @@ def create_or_update_hook(self, project, hook_url, options):
hook.save()
except Exception as e:
self._module.fail_json(msg="Failed to update hook: %s " % e)
return True
else:
return False

return changed

'''
@param project Project Object
Expand All @@ -257,9 +256,9 @@ def update_hook(self, hook, arguments):
changed = False

for arg_key, arg_value in arguments.items():
if arguments[arg_key] is not None:
if getattr(hook, arg_key, None) != arguments[arg_key]:
setattr(hook, arg_key, arguments[arg_key])
if arg_value is not None:
if getattr(hook, arg_key, None) != arg_value:
setattr(hook, arg_key, arg_value)
changed = True

return (changed, hook)
Expand Down Expand Up @@ -287,10 +286,8 @@ def exists_hook(self, project, hook_url):
return False

def delete_hook(self):
if self._module.check_mode:
return True

return self.hook_object.delete()
if not self._module.check_mode:
self.hook_object.delete()


def main():
Expand Down