Repository: buildbot/buildbot

Issue:
reporters.gitlab: Use correct state
Fix mistake in code that uses incorrect state for gitlab.



Discussion:

Resolving patch:
diff --git a/master/buildbot/process/properties.py b/master/buildbot/process/properties.py
--- a/master/buildbot/process/properties.py
+++ b/master/buildbot/process/properties.py
@@ -200,17 +200,6 @@ class _PropertyMap(object):
     colon_minus_re = re.compile(r"(.*):-(.*)")
     colon_tilde_re = re.compile(r"(.*):~(.*)")
     colon_plus_re = re.compile(r"(.*):\+(.*)")
-    
-    colon_ternary_re = re.compile(r"""(?P<prop>.*) # the property to match
-                                      :            # colon
-                                      (?P<alt>\#)? # might have the alt marker '#'
-                                      \?           # question mark
-                                      (?P<delim>.) # the delimiter
-                                      (?P<true>.*) # sub-if-true
-                                      (?P=delim)   # the delimiter again
-                                      (?P<false>.*)# sub-if-false
-                                      """, re.VERBOSE)
-
     def __init__(self, properties):
         # use weakref here to avoid a reference loop
         self.properties = weakref.ref(properties)
@@ -251,38 +240,10 @@ def colon_plus(mo):
             else:
                 return ''
 
-        def colon_ternary(mo):
-            # %(prop:?:T:F)s
-            # if prop exists, use T; otherwise, F
-            # %(prop:#?:T:F)s
-            # if prop is true, use T; otherwise, F
-            groups = mo.groupdict()
-            
-            prop = groups['prop']
-            
-            if prop in self.temp_vals:
-                if groups['alt']:
-                    use_true = self.temp_vals[prop]
-                else:
-                    use_true = True
-            elif properties.has_key(prop):
-                if groups['alt']:
-                    use_true = properties[prop]
-                else:
-                    use_true = True
-            else:
-                use_true = False
-            
-            if use_true:
-                return groups['true']
-            else:
-                return groups['false']
-
         for regexp, fn in [
             ( self.colon_minus_re, colon_minus ),
             ( self.colon_tilde_re, colon_tilde ),
             ( self.colon_plus_re, colon_plus ),
-            ( self.colon_ternary_re, colon_ternary ),
             ]:
             mo = regexp.match(key)
             if mo:


Test patch:
diff --git a/master/buildbot/test/unit/test_process_properties.py b/master/buildbot/test/unit/test_process_properties.py
--- a/master/buildbot/test/unit/test_process_properties.py
+++ b/master/buildbot/test/unit/test_process_properties.py
@@ -198,58 +198,6 @@ def testColonPlusEmpty(self):
     def testColonPlusUnset(self):
         return self.doTestSimpleWithProperties('%(prop_nosuch:+present)s', '')
 
-
-    def testColonTernarySet(self):
-        return self.doTestSimpleWithProperties('%(prop_str:?:present:missing)s', 'present')
-
-    def testColonTernaryNone(self):
-        return self.doTestSimpleWithProperties('%(prop_none:?:present:missing)s', 'present')
-
-    def testColonTernaryZero(self):
-        return self.doTestSimpleWithProperties('%(prop_zero:?|present|missing)s', 'present')
-
-    def testColonTernaryOne(self):
-        return self.doTestSimpleWithProperties('%(prop_one:?:present:missing)s', 'present')
-
-    def testColonTernaryFalse(self):
-        return self.doTestSimpleWithProperties('%(prop_false:?|present|missing)s', 'present')
-
-    def testColonTernaryTrue(self):
-        return self.doTestSimpleWithProperties('%(prop_true:?:present:missing)s', 'present')
-
-    def testColonTernaryEmpty(self):
-        return self.doTestSimpleWithProperties('%(prop_empty:?ApresentAmissing)s', 'present')
-
-    def testColonTernaryUnset(self):
-        return self.doTestSimpleWithProperties('%(prop_nosuch:?#present#missing)s', 'missing')
-
-
-    def testColonTernaryHashSet(self):
-        return self.doTestSimpleWithProperties('%(prop_str:#?:truish:falsish)s', 'truish')
-        
-    def testColonTernaryHashNone(self):
-        # None is special-cased *differently* for '#?'
-        return self.doTestSimpleWithProperties('%(prop_none:#?|truish|falsish)s', 'falsish')
-
-    def testColonTernaryHashZero(self):
-        return self.doTestSimpleWithProperties('%(prop_zero:#?:truish:falsish)s', 'falsish')
-
-    def testColonTernaryHashOne(self):
-        return self.doTestSimpleWithProperties('%(prop_one:#?:truish:falsish)s', 'truish')
-
-    def testColonTernaryHashFalse(self):
-        return self.doTestSimpleWithProperties('%(prop_false:#?:truish:falsish)s', 'falsish')
-
-    def testColonTernaryHashTrue(self):
-        return self.doTestSimpleWithProperties('%(prop_true:#?|truish|falsish)s', 'truish')
-
-    def testColonTernaryHashEmpty(self):
-        return self.doTestSimpleWithProperties('%(prop_empty:#?:truish:falsish)s', 'falsish')
-
-    def testColonTernaryHashUnset(self):
-        return self.doTestSimpleWithProperties('%(prop_nosuch:#?.truish.falsish)s', 'falsish')
-
-
     def testClearTempValues(self):
         d = self.doTestSimpleWithProperties('', '',
                 prop_temp=lambda b: 'present')
@@ -327,23 +275,6 @@ def testTempValuePlusUnsetSet(self):
                 prop_nosuch=lambda b: 1)
 
 
-    def testTempValueColonTernaryTrue(self):
-        return self.doTestSimpleWithProperties('%(prop_temp:?:present:missing)s', 'present',
-                prop_temp=lambda b: True)
-
-    def testTempValueColonTernaryFalse(self):
-        return self.doTestSimpleWithProperties('%(prop_temp:?|present|missing)s', 'present',
-                prop_temp=lambda b: False)
-
-    def testTempValueColonTernaryHashTrue(self):
-        return self.doTestSimpleWithProperties('%(prop_temp:#?|truish|falsish)s', 'truish',
-                prop_temp=lambda b: 1)
-
-    def testTempValueColonTernaryHashFalse(self):
-        return self.doTestSimpleWithProperties('%(prop_temp:#?|truish|falsish)s', 'falsish',
-                prop_nosuch=lambda b: 0)
-
-
 class TestInterpolateConfigure(unittest.TestCase, ConfigErrorsMixin):
     """
     Test that Interpolate reports erros in the interpolation string
@@ -870,15 +801,6 @@ def testDictColonPlus(self):
                              "build-exists-.tar.gz")
         return d
 
-    def testDictColonTernary(self):
-        # test dict-style substitution with WithProperties
-        self.props.setProperty("prop1", "foo", "test")
-        command = WithProperties("build-%(prop1:?:exists:missing)s-%(prop2:?:exists:missing)s.tar.gz")
-        d = self.build.render(command)
-        d.addCallback(self.failUnlessEqual,
-                             "build-exists-missing.tar.gz")
-        return d
-
     def testEmpty(self):
         # None should render as ''
         self.props.setProperty("empty", None, "test")