summaryrefslogtreecommitdiff
path: root/ybd/pots.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-02-21 17:28:51 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-02-21 17:55:07 +0900
commit8531759bdbc1cd7ad5c206c9a9cbe25692d46dad (patch)
treec2409c694800382862ff89a90e18e49a3362a034 /ybd/pots.py
parent84acd9ab40b8529b3573e800873ef90a4d45bd9a (diff)
downloadybd-8531759bdbc1cd7ad5c206c9a9cbe25692d46dad.tar.gz
Store the original 'ref' and restore it before savingtristan-build-sha-if-exists
In case it was overridden by the 'sha' field for the purpose of building, we still want to export the original 'ref' field in the saved target.yml
Diffstat (limited to 'ybd/pots.py')
-rw-r--r--ybd/pots.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/ybd/pots.py b/ybd/pots.py
index ec11d94..a66686e 100644
--- a/ybd/pots.py
+++ b/ybd/pots.py
@@ -16,6 +16,7 @@
import os
import yaml
+import copy
from app import config, log
from defaults import Defaults
from morphs import Morphs
@@ -62,8 +63,17 @@ class Pots(object):
return self._data.get(dn.get('path', dn.keys()[0]))
def save(self, filename):
+
+ # Make a copy, restore any refs which may have been overridden
+ # with the sha field while building.
+ data = copy.deepcopy(self._data)
+ for key, value in data.items():
+ if value.get('orig_ref') is not None:
+ value['ref'] = value['orig_ref']
+ del value['orig_ref']
+
with open(filename, 'w') as f:
- f.write(yaml.dump(self._data, default_flow_style=False,
+ f.write(yaml.dump(data, default_flow_style=False,
Dumper=ExplicitDumper))
log('CHECK', 'Saved yaml definitions at', filename)