From: Frank Brehm Date: Fri, 31 Aug 2018 08:11:48 +0000 (+0200) Subject: Only displaing modules, which are used in main branches X-Git-Tag: 0.10.11^2 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=aff9696fff23fe0ff47295351821ce0aa7608651;p=pixelpark%2Fpuppetmaster-webhooks.git Only displaing modules, which are used in main branches --- diff --git a/lib/webhooks/__init__.py b/lib/webhooks/__init__.py index c0ace1b..0fafd58 100644 --- a/lib/webhooks/__init__.py +++ b/lib/webhooks/__init__.py @@ -1,6 +1,6 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '0.10.10' +__version__ = '0.10.11' # vim: ts=4 et list diff --git a/lib/webhooks/show_modules.py b/lib/webhooks/show_modules.py index 8456298..633bc7e 100644 --- a/lib/webhooks/show_modules.py +++ b/lib/webhooks/show_modules.py @@ -59,6 +59,8 @@ class ShowModulesApp(BaseHookApp): 'errors': 'surrogateescape', } + main_branches = ('development', 'test', 'production') + # ------------------------------------------------------------------------- def __init__(self, output_type='json', appname=None, verbose=0, version=__version__): """Constructor.""" @@ -88,6 +90,7 @@ class ShowModulesApp(BaseHookApp): res = super(ShowModulesApp, self).as_dict() res['open_args'] = self.open_args + res['main_branches'] = copy.copy(self.main_branches) return res @@ -395,7 +398,7 @@ class ShowModulesApp(BaseHookApp): return output_data # ------------------------------------------------------------------------- - def read_cache_file(self): + def read_cache_file(self, only_main_branches=True): LOG.debug("Searching for {!r} ...".format(self.cache_file)) if not os.path.exists(self.cache_file): @@ -415,6 +418,19 @@ class ShowModulesApp(BaseHookApp): struct, appname=self.appname, verbose=self.verbose, base_dir=self.base_dir) if module_info: + if only_main_branches: + in_main_branches = False + for branch in self.main_branches: + if (branch in module_info.local_versions and + module_info.local_versions[branch]): + in_main_branches = True + elif (branch in module_info.expected_versions and + module_info.expected_versions[branch]): + in_main_branches = True + if in_main_branches: + break + if not in_main_branches: + continue if self.should_display(module_info): data.append(module_info) except yaml.YAMLError as e: