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

subversion: PEP8 compliancy and doc fixes #30909

Merged
merged 1 commit into from
Oct 30, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
100 changes: 40 additions & 60 deletions lib/ansible/modules/source_control/subversion.py
Original file line number Diff line number Diff line change
@@ -1,115 +1,98 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
# Copyright: (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
__metaclass__ = type


ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'core'}


DOCUMENTATION = '''
---
module: subversion
short_description: Deploys a subversion repository.
short_description: Deploys a subversion repository
description:
- Deploy given repository URL / revision to dest. If dest exists, update to the specified revision, otherwise perform a checkout.
version_added: "0.7"
author: "Dane Summers (@dsummersl) <njharman@gmail.com>"
author:
- Dane Summers (@dsummersl) <njharman@gmail.com>
notes:
- Requires I(svn) to be installed on the client.
- This module does not handle externals
requirements: []
- This module does not handle externals.
options:
repo:
description:
- The subversion URL to the repository.
required: true
aliases: [ name, repository ]
default: null
dest:
description:
- Absolute path where the repository should be deployed.
required: true
default: null
revision:
description:
- Specific revision to checkout.
required: false
default: HEAD
aliases: [ version ]
force:
description:
- If C(yes), modified files will be discarded. If C(no), module will fail if it encounters modified files.
Prior to 1.9 the default was `yes`.
required: false
Prior to 1.9 the default was C(yes).
type: bool
default: "no"
choices: [ "yes", "no" ]
username:
description:
- --username parameter passed to svn.
required: false
default: null
- C(--username) parameter passed to svn.
password:
description:
- --password parameter passed to svn.
required: false
default: null
- C(--password) parameter passed to svn.
executable:
required: false
default: null
version_added: "1.4"
description:
- Path to svn executable to use. If not supplied,
the normal mechanism for resolving binary paths will be used.
version_added: "1.4"
checkout:
required: false
description:
- If C(no), do not check out the repository if it does not exist locally.
type: bool
default: "yes"
choices: [ "yes", "no" ]
version_added: "2.3"
description:
- If no, do not check out the repository if it does not exist locally
update:
required: false
description:
- If C(no), do not retrieve new revisions from the origin repository.
type: bool
default: "yes"
choices: [ "yes", "no" ]
version_added: "2.3"
description:
- If no, do not retrieve new revisions from the origin repository
export:
required: false
default: "no"
choices: [ "yes", "no" ]
version_added: "1.6"
description:
- If C(yes), do export instead of checkout/update.
type: bool
default: "no"
version_added: "1.6"
switch:
required: false
default: "yes"
choices: [ "yes", "no" ]
version_added: "2.0"
description:
- If C(no), do not call svn switch before update.
default: "yes"
version_added: "2.0"
type: bool
'''

EXAMPLES = '''
# Checkout subversion repository to specified folder.
- subversion:
- name: Checkout subversion repository to specified folder
subversion:
repo: svn+ssh://an.example.org/path/to/repo
dest: /src/checkout

# Export subversion directory to folder
- subversion:
- name: Export subversion directory to folder
subversion:
repo: svn+ssh://an.example.org/path/to/repo
dest: /src/export

# Example just get information about the repository whether or not it has
# already been cloned locally.
- name: Get information about the repository whether or not it has already been cloned locally
- subversion:
repo: svn+ssh://an.example.org/path/to/repo
dest: /srv/checkout
Expand All @@ -124,8 +107,7 @@


class Subversion(object):
def __init__(
self, module, dest, repo, revision, username, password, svn_path):
def __init__(self, module, dest, repo, revision, username, password, svn_path):
self.module = module
self.dest = dest
self.repo = repo
Expand Down Expand Up @@ -199,7 +181,7 @@ def get_remote_revision(self):

def has_local_mods(self):
'''True if revisioned files have been added or modified. Unrevisioned files are ignored.'''
lines = self._exec(["status", "--quiet", "--ignore-externals", self.dest])
lines = self._exec(["status", "--quiet", "--ignore-externals", self.dest])
# The --quiet option will return only modified files.
# Match only revisioned files, i.e. ignore status '?'.
regex = re.compile(r'^[^?X]')
Expand All @@ -218,24 +200,22 @@ def needs_update(self):
return change, curr, head


# ===========================================

def main():
module = AnsibleModule(
argument_spec=dict(
dest=dict(type='path'),
repo=dict(required=True, aliases=['name', 'repository']),
revision=dict(default='HEAD', aliases=['rev', 'version']),
force=dict(default='no', type='bool'),
username=dict(required=False),
password=dict(required=False, no_log=True),
executable=dict(default=None, type='path'),
export=dict(default=False, required=False, type='bool'),
checkout=dict(default=True, required=False, type='bool'),
update=dict(default=True, required=False, type='bool'),
switch=dict(default=True, required=False, type='bool'),
repo=dict(type='str', required=True, aliases=['name', 'repository']),
revision=dict(type='str', default='HEAD', aliases=['rev', 'version']),
force=dict(type='bool', default=False),
username=dict(type='str'),
password=dict(type='str', no_log=True),
executable=dict(type='path'),
export=dict(type='bool', default=False),
checkout=dict(type='bool', default=True),
update=dict(type='bool', default=True),
switch=dict(type='bool', default=True),
),
supports_check_mode=True
supports_check_mode=True,
)

dest = module.params['dest']
Expand Down
1 change: 0 additions & 1 deletion test/sanity/pep8/legacy-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ lib/ansible/modules/remote_management/foreman/katello.py
lib/ansible/modules/remote_management/stacki/stacki_host.py
lib/ansible/modules/source_control/bzr.py
lib/ansible/modules/source_control/hg.py
lib/ansible/modules/source_control/subversion.py
lib/ansible/modules/storage/infinidat/infini_export.py
lib/ansible/modules/storage/infinidat/infini_export_client.py
lib/ansible/modules/storage/infinidat/infini_fs.py
Expand Down