Fix handling of multi-part branches in the build triggers

Fixes #1360
This commit is contained in:
Joseph Schorr 2016-07-26 13:41:13 -07:00
parent 9d48bcd0f1
commit 06d52f2c83
7 changed files with 232 additions and 21 deletions

View file

@ -16,6 +16,8 @@ class TestRegex(unittest.TestCase):
self.assertMatches('ref/heads/master', '.+')
self.assertMatches('ref/heads/master', 'heads/.+')
self.assertMatches('ref/heads/master', 'heads/master')
self.assertMatches('ref/heads/slash/branch', 'heads/slash/branch')
self.assertMatches('ref/heads/slash/branch', 'heads/.+')
self.assertDoesNotMatch('ref/heads/foobar', 'heads/master')
self.assertDoesNotMatch('ref/heads/master', 'tags/master')
@ -28,6 +30,27 @@ class TestRegex(unittest.TestCase):
self.assertDoesNotMatch('ref/heads/delta', '(((heads/alpha)|(heads/beta))|(heads/gamma))|(heads/master)')
class TestTags(unittest.TestCase):
def assertTagsForRef(self, ref, tags):
prepared = PreparedBuild()
prepared.tags_from_ref(ref, default_branch='master')
self.assertEquals(tags, prepared._tags)
def test_normal(self):
self.assertTagsForRef('ref/heads/somebranch', ['somebranch'])
self.assertTagsForRef('ref/heads/master', ['master', 'latest'])
self.assertTagsForRef('ref/tags/somebranch', ['somebranch'])
self.assertTagsForRef('ref/tags/master', ['master', 'latest'])
def test_slash(self):
self.assertTagsForRef('ref/heads/slash/branch', ['slash_branch'])
self.assertTagsForRef('ref/tags/slash/tag', ['slash_tag'])
def test_unusual(self):
self.assertTagsForRef('ref/heads/foobar#2', ['foobar_2'])
class TestSkipBuild(unittest.TestCase):
def testSkipNoMetadata(self):
prepared = PreparedBuild()