Merge "add validation for branch name prefixes"
This commit is contained in:
commit
8f2d2c4295
openstack_releases
@ -57,6 +57,11 @@ _VALID_TYPES = set([
|
||||
'service',
|
||||
'other',
|
||||
])
|
||||
_VALID_BRANCH_PREFIXES = set([
|
||||
'stable',
|
||||
'feature',
|
||||
'driverfixes',
|
||||
])
|
||||
|
||||
|
||||
def is_a_hash(val):
|
||||
@ -338,6 +343,25 @@ def validate_new_releases(deliverable_info, filename,
|
||||
)
|
||||
|
||||
|
||||
def validate_branch_prefixes(deliverable_info, mk_waring, mk_error):
|
||||
"Ensure all branches have good prefixes."
|
||||
branches = deliverable_info.get('branches', [])
|
||||
for branch in branches:
|
||||
prefix = branch['name'].split('/')[0]
|
||||
if prefix not in _VALID_BRANCH_PREFIXES:
|
||||
mk_error('branch name %s does not use a valid prefix: %s' % (
|
||||
branch['name'], _VALID_BRANCH_PREFIXES))
|
||||
|
||||
|
||||
# if the branch already exists, the name is by definition valid
|
||||
# feature branches map between repo names and SHA values
|
||||
# stable branches use one of the valid series names
|
||||
# stable branches map to a single version number
|
||||
# driverfixes branches map between repo names and SHA or version number
|
||||
# if the branch exists, the data in the map must match reality
|
||||
# if the branch does not exist, the references in the map must exist
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
@ -423,6 +447,11 @@ def main():
|
||||
mk_warning,
|
||||
mk_error,
|
||||
)
|
||||
validate_branch_prefixes(
|
||||
deliverable_info,
|
||||
mk_warning,
|
||||
mk_error,
|
||||
)
|
||||
|
||||
if warnings:
|
||||
print('\n\n%s warnings found' % len(warnings))
|
||||
|
@ -643,3 +643,40 @@ class TestValidateNewReleases(base.BaseTestCase):
|
||||
)
|
||||
self.assertEqual(1, len(warnings))
|
||||
self.assertEqual(0, len(errors))
|
||||
|
||||
|
||||
class TestValidateBranchPrefixes(base.BaseTestCase):
|
||||
|
||||
def test_invalid_prefix(self):
|
||||
deliverable_info = {
|
||||
'branches': [
|
||||
{'name': 'invalid/branch'},
|
||||
],
|
||||
}
|
||||
warnings = []
|
||||
errors = []
|
||||
validate.validate_branch_prefixes(
|
||||
deliverable_info,
|
||||
warnings.append,
|
||||
errors.append,
|
||||
)
|
||||
self.assertEqual(0, len(warnings))
|
||||
self.assertEqual(1, len(errors))
|
||||
|
||||
def test_valid_prefix(self):
|
||||
warnings = []
|
||||
errors = []
|
||||
for prefix in validate._VALID_BRANCH_PREFIXES:
|
||||
deliverable_info = {
|
||||
'branches': [
|
||||
{'name': '%s/branch' % prefix},
|
||||
],
|
||||
}
|
||||
validate.validate_branch_prefixes(
|
||||
deliverable_info,
|
||||
warnings.append,
|
||||
errors.append,
|
||||
)
|
||||
self.assertEqual(0, len(warnings))
|
||||
self.assertEqual(0, len(errors))
|
||||
self.assertEqual(0, len(errors))
|
||||
|
Loading…
x
Reference in New Issue
Block a user