aboutsummaryrefslogtreecommitdiff
path: root/control
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2011-09-15 13:30:03 +0300
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2011-09-15 13:30:03 +0300
commitf534fa3d832d741ecd95cd55f7b492d771cbb925 (patch)
treebd85c33b203b58d265bce53c05acc8de38b25b17 /control
parent95ffb2b91c0fc5c212aa4501edeae500a0a0ac08 (diff)
Normalize XML to the format used by Jenkins, to avoid spurious diffs.
Diffstat (limited to 'control')
-rwxr-xr-xcontrol/mangle-jobs10
1 files changed, 8 insertions, 2 deletions
diff --git a/control/mangle-jobs b/control/mangle-jobs
index c5d211b..94a98a4 100755
--- a/control/mangle-jobs
+++ b/control/mangle-jobs
@@ -77,6 +77,12 @@ def getJobConfig(job_name):
def postConfig(url, configXml):
_authJenkins(url, configXml, {'Content-Type': 'text/xml'})
+def render_xml(tree):
+ text = tostring(tree, xml_declaration=True, encoding='UTF-8')
+ line1, rest = text.split("\n", 1)
+ line1 = line1.replace("'", '"')
+ return line1 + rest
+
def show_diff(old, new):
with nested(NamedTemporaryFile(), NamedTemporaryFile()) as (a, b):
a.write(old)
@@ -98,7 +104,7 @@ def process_remote_jenkins():
text = getJobConfig(name)
tree = fromstring(text)
mangler(tree)
- new_text = tostring(tree, xml_declaration=True, encoding='UTF-8')
+ new_text = render_xml(tree)
if not options.really:
show_diff(text, new_text)
else:
@@ -109,7 +115,7 @@ def main():
text = open(options.file).read()
tree = fromstring(text)
mangler(tree)
- new_text = tostring(tree, xml_declaration=True, encoding='UTF-8')
+ new_text = render_xml(tree)
show_diff(text, new_text)
else:
process_remote_jenkins()