diff options
author | Ben Brown <ben.brown@codethink.co.uk> | 2017-08-16 17:45:34 +0100 |
---|---|---|
committer | Ben Brown <ben.brown@codethink.co.uk> | 2017-08-17 10:13:07 +0100 |
commit | eae3581ef54d266b5725b55c7ef68dd966e78822 (patch) | |
tree | 441f9d90f0d6ffd7ea5b8cb021f87d9933bc6cb6 | |
parent | f5e155f66e907b8fed1fa6d26b3a93a989d3626b (diff) | |
download | ybd-eae3581ef54d266b5725b55c7ef68dd966e78822.tar.gz |
Sanitise definition ref/sha when initally inserting into the dictionary
If the definition doesn't already exist in the dictionary, the ref never
gets sanitised. Fixes incorrect checkout of ref instead of sha.
-rw-r--r-- | ybd/morphs.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ybd/morphs.py b/ybd/morphs.py index 203401d..c99b36d 100644 --- a/ybd/morphs.py +++ b/ybd/morphs.py @@ -204,14 +204,6 @@ class Morphs(object): if key is not 'name': dn[key] = new_def[key] - # If a sha was specified, we want to build it instead of the ref - # but preserve the ref in the output <target>.yml file. - if dn.get('sha'): - if len(dn['sha']) != 40: - log(new_def, 'ERROR: invalid sha:', dn['sha'], exit=True) - dn['orig_ref'] = dn['ref'] - dn['ref'] = dn['sha'] - if dn['name'] != new_def['name']: log(new_def, 'WARNING: %s also named as' % new_def['name'], dn['name'], exit=exit) @@ -222,7 +214,16 @@ class Morphs(object): log(new_def, 'WARNING: multiple definitions of %s \n' % key, '%s | %s' % (dn.get(key), new_def[key]), exit=exit) - else: + + # If a sha was specified, we want to build it instead of the ref + # but preserve the ref in the output <target>.yml file. + if new_def.get('sha'): + if len(new_def['sha']) != 40: + log(new_def, 'ERROR: invalid sha:', new_def['sha'], exit=True) + new_def['orig_ref'] = new_def['ref'] + new_def['ref'] = new_def['sha'] + + if dn is None: self._data[new_def['path']] = new_def return new_def['path'] |