mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Support matching original path for a moved module location
This commit is contained in:
parent
694c57de2e
commit
293e624235
1 changed files with 16 additions and 1 deletions
|
@ -270,8 +270,23 @@ class ModuleValidator(Validator):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _get_base_branch_module_path(self):
|
||||||
|
"""List all paths within lib/ansible/modules to try and match a moved module"""
|
||||||
|
command = ['git', 'ls-tree', '-r', '--name-only', self.base_branch, 'lib/ansible/modules/']
|
||||||
|
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
|
|
||||||
|
for path in stdout.splitlines():
|
||||||
|
if path.endswith('/%s' % self.object_name):
|
||||||
|
return path
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def _get_base_file(self):
|
def _get_base_file(self):
|
||||||
command = ['git', 'show', '%s:%s' % (self.base_branch, self.path)]
|
# In case of module moves, look for the original location
|
||||||
|
base_path = self._get_base_branch_module_path()
|
||||||
|
|
||||||
|
command = ['git', 'show', '%s:%s' % (self.base_branch, base_path or self.path)]
|
||||||
p = subprocess.Popen(command, stdout=subprocess.PIPE,
|
p = subprocess.Popen(command, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
|
|
Loading…
Reference in a new issue