From d1d69c6c63c9f2aa9cd7bd8d996264dab1828804 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Thu, 4 Jul 2019 11:03:16 +0100 Subject: [PATCH] Add more difference infrastructure --- differences/dometahierarchy.groovy | 45 ++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/differences/dometahierarchy.groovy b/differences/dometahierarchy.groovy index 0b42152..bbfde2b 100644 --- a/differences/dometahierarchy.groovy +++ b/differences/dometahierarchy.groovy @@ -114,21 +114,42 @@ def getgitlogdifferences(String gitrootfolder, String earlyrevision, String late return differencetext } +def extractsha(String line) { + def pattern = ~"^(.*)\s(.*)" + + def sha = line.replaceFirst(pattern) { _, sha, therest -> "${sha.trim()}" } + def therest = line.replaceFirst(pattern) { _, sha, therest -> "${therest.trim()}" } + + echo "Sha filtering: line: ${line} sha: ${sha} therest: ${therest}" + + return [sha, therest] +} + +def DifferenceRecord fillrecord(meta, line) { + def DifferenceRecord dr = new DifferenceRecord() + + dr.productname = meta.productinfo.productname + dr.subcomponentname = meta.productinfo.subcomponentname + dr.jirakey = meta.productinfo.jirakey + + dr.rawdifferencetext = line + + // Example of raw text to process: + // 76056562e4 GIS-1621 - Removing redundant lines and effects of this - Restore nuget_version_edit.py + + (dr.sha, line) = extractsha(line) + + dr.type = 0 + dr.jiraticketinfo = "info" + + return dr +} + def List processtext(meta, String text) { def List differencerecords = [] - - text.split('\n').each { - def DifferenceRecord dr = new DifferenceRecord() - - dr.productname = meta.productinfo.productname - dr.subcomponentname = meta.productinfo.subcomponentname - dr.jirakey = meta.productinfo.jirakey - dr.rawdifferencetext = it.trim() - dr.sha = "sha" - dr.type = 0 - dr.jiraticketinfo = "info" - + text.split('\n').each { + DifferenceRecord dr = fillrecord(meta, it.trim()) differencerecords.add(dr) } return differencerecords