summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brown <ben.brown@codethink.co.uk>2017-08-16 17:45:34 +0100
committerBen Brown <ben.brown@codethink.co.uk>2017-08-17 10:13:07 +0100
commiteae3581ef54d266b5725b55c7ef68dd966e78822 (patch)
tree441f9d90f0d6ffd7ea5b8cb021f87d9933bc6cb6
parentf5e155f66e907b8fed1fa6d26b3a93a989d3626b (diff)
downloadybd-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.py19
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']