Blame mbs-fix-reuse-buildrequires-change.patch

c49d413
diff --git a/module_build_service/utils/reuse.py b/module_build_service/utils/reuse.py
c49d413
index efbbc0a..d548264 100644
c49d413
--- a/module_build_service/utils/reuse.py
c49d413
+++ b/module_build_service/utils/reuse.py
c49d413
@@ -25,7 +25,7 @@
c49d413
 import kobo.rpmlib
c49d413
 
c49d413
 import module_build_service.messaging
c49d413
-from module_build_service import log, models, conf
c49d413
+from module_build_service import log, models, conf, glib
c49d413
 
c49d413
 
c49d413
 def reuse_component(component, previous_component_build,
c49d413
@@ -110,6 +110,21 @@ def _get_reusable_module(session, module):
c49d413
         log.info("Cannot re-use.  %r is the first module build." % module)
c49d413
         return None
c49d413
 
c49d413
+    xmd = glib.from_variant_dict(mmd.get_xmd())
c49d413
+    old_mmd = previous_module_build.mmd()
c49d413
+    old_xmd = glib.from_variant_dict(old_mmd.get_xmd())
c49d413
+
c49d413
+    # Make sure that the module buildrequires commit hashes are exactly the same
c49d413
+    for br_module_name, br_module in xmd['mbs']['buildrequires'].items():
c49d413
+        # Assumes that the streams have been replaced with commit hashes, so we
c49d413
+        # can compare to see if they have changed. Since a build is unique to
c49d413
+        # a commit hash, this is a safe test.
c49d413
+        ref1 = br_module.get('ref')
c49d413
+        ref2 = old_xmd['mbs']['buildrequires'][br_module_name].get('ref')
c49d413
+        if not (ref1 and ref2) or ref1 != ref2:
c49d413
+            log.info('Cannot re-use.  The buildrequired module %s ref hash changed', br_module_name)
c49d413
+            return None
c49d413
+
c49d413
     return previous_module_build
c49d413
 
c49d413