Merge "SourceContext: add same_project comparison" into feature/zuulv3
diff --git a/zuul/configloader.py b/zuul/configloader.py
index b70ea59..7722a7e 100644
--- a/zuul/configloader.py
+++ b/zuul/configloader.py
@@ -513,7 +513,7 @@
                 raise SecretNotFoundError(secret_name)
             if secret_name == 'zuul':
                 raise Exception("Secrets named 'zuul' are not allowed.")
-            if secret.source_context != job.source_context:
+            if not secret.source_context.isSameProject(job.source_context):
                 raise Exception(
                     "Unable to use secret %s.  Secrets must be "
                     "defined in the same project in which they "
diff --git a/zuul/model.py b/zuul/model.py
index 0e42368..4c5a51f 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -627,6 +627,13 @@
         return self.__class__(self.project, self.branch, self.path,
                               self.trusted)
 
+    def isSameProject(self, other):
+        if not isinstance(other, SourceContext):
+            return False
+        return (self.project == other.project and
+                self.branch == other.branch and
+                self.trusted == other.trusted)
+
     def __ne__(self, other):
         return not self.__eq__(other)