mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Subversion: checking out with existing content (#38366)
* Subversion: If the directory exists, we want the ability to checkout into it and use the content as existing files; equivalent to svn checkout --force I was expecting the force option to do this, however I understand why it doesn't do that currently. I was debating with changing the meaning of force to include this behaviour, however I've opted for a seperate flag for now for backwards compatibility. * Subversion: Sanity tests have failed suggesting this is the correct value https://app.shippable.com/github/ansible/ansible/runs/60302/1/console
This commit is contained in:
parent
2f5f57a78f
commit
be8559bfa9
1 changed files with 21 additions and 2 deletions
23
lib/ansible/modules/source_control/subversion.py
Normal file → Executable file
23
lib/ansible/modules/source_control/subversion.py
Normal file → Executable file
|
@ -44,6 +44,13 @@ options:
|
||||||
Prior to 1.9 the default was C(yes).
|
Prior to 1.9 the default was C(yes).
|
||||||
type: bool
|
type: bool
|
||||||
default: "no"
|
default: "no"
|
||||||
|
in_place:
|
||||||
|
description:
|
||||||
|
- If the directory exists, then the working copy will be checked-out over-the-top using
|
||||||
|
svn checkout --force; if force is specified then existing files with different content are reverted
|
||||||
|
type: bool
|
||||||
|
default: "no"
|
||||||
|
version_added: "2.6"
|
||||||
username:
|
username:
|
||||||
description:
|
description:
|
||||||
- C(--username) parameter passed to svn.
|
- C(--username) parameter passed to svn.
|
||||||
|
@ -140,9 +147,13 @@ class Subversion(object):
|
||||||
rc = self._exec(["info", self.dest], check_rc=False)
|
rc = self._exec(["info", self.dest], check_rc=False)
|
||||||
return rc == 0
|
return rc == 0
|
||||||
|
|
||||||
def checkout(self):
|
def checkout(self, force=False):
|
||||||
'''Creates new svn working directory if it does not already exist.'''
|
'''Creates new svn working directory if it does not already exist.'''
|
||||||
self._exec(["checkout", "-r", self.revision, self.repo, self.dest])
|
cmd = ["checkout"]
|
||||||
|
if force:
|
||||||
|
cmd.append("--force")
|
||||||
|
cmd.extend(["-r", self.revision, self.repo, self.dest])
|
||||||
|
self._exec(cmd)
|
||||||
|
|
||||||
def export(self, force=False):
|
def export(self, force=False):
|
||||||
'''Export svn repo to directory'''
|
'''Export svn repo to directory'''
|
||||||
|
@ -214,6 +225,7 @@ def main():
|
||||||
checkout=dict(type='bool', default=True),
|
checkout=dict(type='bool', default=True),
|
||||||
update=dict(type='bool', default=True),
|
update=dict(type='bool', default=True),
|
||||||
switch=dict(type='bool', default=True),
|
switch=dict(type='bool', default=True),
|
||||||
|
in_place=dict(type='bool', default=False),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
@ -229,6 +241,7 @@ def main():
|
||||||
switch = module.params['switch']
|
switch = module.params['switch']
|
||||||
checkout = module.params['checkout']
|
checkout = module.params['checkout']
|
||||||
update = module.params['update']
|
update = module.params['update']
|
||||||
|
in_place = module.params['in_place']
|
||||||
|
|
||||||
# We screenscrape a huge amount of svn commands so use C locale anytime we
|
# We screenscrape a huge amount of svn commands so use C locale anytime we
|
||||||
# call run_command()
|
# call run_command()
|
||||||
|
@ -273,6 +286,12 @@ def main():
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg="ERROR: modified files exist in the repository.")
|
module.fail_json(msg="ERROR: modified files exist in the repository.")
|
||||||
svn.update()
|
svn.update()
|
||||||
|
elif in_place:
|
||||||
|
before = None
|
||||||
|
svn.checkout(force=True)
|
||||||
|
local_mods = svn.has_local_mods()
|
||||||
|
if local_mods and force:
|
||||||
|
svn.revert()
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg="ERROR: %s folder already exists, but its not a subversion repository." % (dest,))
|
module.fail_json(msg="ERROR: %s folder already exists, but its not a subversion repository." % (dest,))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue