]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Only displaing modules, which are used in main branches
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 31 Aug 2018 08:11:48 +0000 (10:11 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 31 Aug 2018 08:11:48 +0000 (10:11 +0200)
lib/webhooks/__init__.py
lib/webhooks/show_modules.py

index c0ace1badf9d09ca02601782a1337a4b4159f79e..0fafd5879ba9fdef6647c67579d3059f17a5a6a1 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/env python3
 # -*- coding: utf-8 -*-
 
-__version__ = '0.10.10'
+__version__ = '0.10.11'
 
 # vim: ts=4 et list
index 845629894ad21bf2ca4a561926a8f889310fbc89..633bc7e57e5a71f9ee4efdd46c422529472ef245 100644 (file)
@@ -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: