summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sherwood <paul.sherwood@codethink.co.uk>2017-02-20 12:23:34 +0000
committerPaul Sherwood <paul.sherwood@codethink.co.uk>2017-02-20 14:18:41 +0000
commit84acd9ab40b8529b3573e800873ef90a4d45bd9a (patch)
tree5a83145d87d64def4ffd4b5202fe70126e387ca7
parenta8abc3d9311a77a539ea27d67257693f2a1667da (diff)
downloadybd-ps-sha-overrides-ref.tar.gz
If definition contains sha:, it always overrides ref:ps-sha-overrides-ref
-rw-r--r--ybd/config/defaults.conf1
-rw-r--r--ybd/morphs.py8
-rw-r--r--ybd/repos.py2
3 files changed, 10 insertions, 1 deletions
diff --git a/ybd/config/defaults.conf b/ybd/config/defaults.conf
index f44bb8b..8a20f31 100644
--- a/ybd/config/defaults.conf
+++ b/ybd/config/defaults.conf
@@ -19,6 +19,7 @@ morph-fields: ['arch',
'strata',
'ref',
'repo',
+ 'sha',
'subsystems',
'submodules',
'systems',
diff --git a/ybd/morphs.py b/ybd/morphs.py
index a317f76..605af0b 100644
--- a/ybd/morphs.py
+++ b/ybd/morphs.py
@@ -187,12 +187,20 @@ class Morphs(object):
and the new definition both contain a 'ref'. If any keys are
duplicated in the existing definition, output a warning.
+ If `new_def` contains a sha: field (which needs to be 40 chars),
+ this overrides ref: field
+
'''
exit = (config.get('check-definitions') == 'exit')
dn = self._data.get(new_def['path'])
if dn:
+ if dn.get('sha'):
+ if len(dn['sha']) != 40:
+ log(new_def, 'ERROR: invalid sha:', dn['sha'], exit=True)
+ dn['ref'] = dn['sha']
+
if (dn.get('ref') is None or new_def.get('ref') is None):
for key in new_def:
if key is not 'name':
diff --git a/ybd/repos.py b/ybd/repos.py
index 684be30..cbf53a0 100644
--- a/ybd/repos.py
+++ b/ybd/repos.py
@@ -88,7 +88,7 @@ def get_last_tag(gitdir):
def get_tree(dn):
- ref = str(dn['ref'])
+ ref = str(dn.get('ref', str(dn.get('sha'))))
track = app.config.get('track-branches')
if dn.get('unpetrify-ref') and track:
if track is True or dn['path'] in track: