mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Update subversion module to work better with check mode
Adds needs_update() method which will inspect the checkout for the current revision and then the HEAD. If the local check out is behind HEAD, this will report changed=True and supply the revision numbers.
This commit is contained in:
parent
ca16a91da1
commit
bd64641400
1 changed files with 13 additions and 1 deletions
|
@ -120,6 +120,17 @@ class Subversion(object):
|
|||
# Has local mods if more than 0 modifed revisioned files.
|
||||
return len(filter(regex.match, lines)) > 0
|
||||
|
||||
def needs_update(self):
|
||||
curr, url = self.get_revision()
|
||||
out2 = '\n'.join(self._exec("info -r HEAD '%s'" % self.dest))
|
||||
head = re.search(r'^Revision:.*$', out2, re.MULTILINE).group(0)
|
||||
rev1 = int(curr.split(':')[1].strip())
|
||||
rev2 = int(head.split(':')[1].strip())
|
||||
change = False
|
||||
if rev1 < rev2:
|
||||
change = True
|
||||
return change, curr, head
|
||||
|
||||
|
||||
# ===========================================
|
||||
|
||||
|
@ -156,7 +167,8 @@ def main():
|
|||
# positives. Need to switch before revert to ensure we are reverting to
|
||||
# correct repo.
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
check, before, after = svn.needs_update()
|
||||
module.exit_json(changed=check, before=before, after=after)
|
||||
before = svn.get_revision()
|
||||
local_mods = svn.has_local_mods()
|
||||
svn.switch()
|
||||
|
|
Loading…
Reference in a new issue