Handle v0.1 and v0.2 formats simultaneously
This commit is contained in:
parent
a64688112a
commit
2ba37172e4
1 changed files with 78 additions and 13 deletions
|
|
@ -590,15 +590,52 @@ class MetaInfo extends GISJsonSerialised {
|
|||
private static String METAFOLDERNAME = 'meta'
|
||||
private static String METAFILENAME = 'info.json'
|
||||
private static String METAARTIFACTS = "${METAFOLDERNAME}/**"
|
||||
private static String format = '0.2'
|
||||
|
||||
class RelatedMetaInfo extends GISJsonSerialised {
|
||||
trait RelatedMetaInfo extends GISJsonSerialised {
|
||||
private String format
|
||||
|
||||
RelatedMetaInfo(script, format) {
|
||||
super(script)
|
||||
this.format = format
|
||||
}
|
||||
|
||||
abstract void deserialiseJson(rawmeta)
|
||||
abstract LinkedHashMap serialisationdata()
|
||||
}
|
||||
|
||||
class RelatedMetaInfo_v0_1 extends RelatedMetaInfo {
|
||||
String offsetpath
|
||||
MetaInfo meta
|
||||
|
||||
RelatedMetaInfo_v0_1(script, offsetpath = "", MetaInfo meta = null) {
|
||||
super(script, '0.1')
|
||||
this.offsetpath = offsetpath
|
||||
this.meta = meta
|
||||
}
|
||||
|
||||
void deserialiseJson(rawmeta) {
|
||||
offsetpath = rawmeta['offsetpath']
|
||||
meta = new MetaInfo(script)
|
||||
meta.deserialiseJson(rawmeta['meta'])
|
||||
}
|
||||
|
||||
LinkedHashMap serialisationdata() {
|
||||
def data = [
|
||||
'format' : format,
|
||||
'offsetpath' : offsetpath,
|
||||
'meta' : meta.serialisationdata(),
|
||||
]
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
class RelatedMetaInfo_v0_2 extends RelatedMetaInfo {
|
||||
private String importpath
|
||||
private String offsetpath
|
||||
|
||||
RelatedMetaInfo(script, importpath = "", offsetpath = "") {
|
||||
super(script)
|
||||
this.format = '0.2'
|
||||
RelatedMetaInfo_v0_2(script, importpath = "", offsetpath = "") {
|
||||
super(script, '0.2')
|
||||
this.importpath = importpath
|
||||
this.offsetpath = offsetpath
|
||||
}
|
||||
|
|
@ -617,7 +654,6 @@ class MetaInfo extends GISJsonSerialised {
|
|||
}
|
||||
}
|
||||
|
||||
private String format = '0.1'
|
||||
private ProductInfo productinfo
|
||||
private GitInfo gitinfo
|
||||
private JenkinsBuildInfo jenkinsbuildinfo
|
||||
|
|
@ -705,7 +741,7 @@ class MetaInfo extends GISJsonSerialised {
|
|||
}
|
||||
|
||||
void deserialiseJson(rawmeta) {
|
||||
if (rawmeta['format'] != '0.1' ) {
|
||||
if (rawmeta['format'] != '0.1' || rawmeta['format'] != '0.2' ) {
|
||||
script.error("Unsupported meta format found at ${filepath}")
|
||||
return
|
||||
}
|
||||
|
|
@ -727,9 +763,15 @@ class MetaInfo extends GISJsonSerialised {
|
|||
}
|
||||
custominfo = rawmeta['custominfo']
|
||||
for (rawrelatedmeta in rawmeta['associatedmeta']) {
|
||||
def rm = new RelatedMetaInfo(script)
|
||||
rm.deserialiseJson(rawrelatedmeta)
|
||||
associatedmeta.add(rm)
|
||||
if (rawrelatedmeta['format'] == nul || rawrelatedmeta['format'] == '0.1') {
|
||||
def rm = new RelatedMetaInfo_v0_1(script)
|
||||
rm.deserialiseJson(rawrelatedmeta)
|
||||
associatedmeta.add(rm)
|
||||
} else if (rawrelatedmeta['format'] == '0.2') {
|
||||
def rm = new RelatedMetaInfo_v0_2(script)
|
||||
rm.deserialiseJson(rawrelatedmeta)
|
||||
associatedmeta.add(rm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -783,7 +825,7 @@ class MetaInfo extends GISJsonSerialised {
|
|||
mi.addConfigurationInfo('', givenRepo, givenRevision, givenSHA)
|
||||
}
|
||||
|
||||
RelatedMetaInfo rmi = new RelatedMetaInfo(script, importedmetafile, adjustedpath)
|
||||
RelatedMetaInfo rmi = new RelatedMetaInfo_v0_2(script, importedmetafile, adjustedpath)
|
||||
if (appendtoparentmeta) {
|
||||
associatedmeta.add(rmi)
|
||||
}
|
||||
|
|
@ -952,6 +994,24 @@ class MetaInfo extends GISJsonSerialised {
|
|||
return childmetainfo
|
||||
}
|
||||
|
||||
def walkrelated_v0_1(ArrayList<MetaInfo> metacollection, String comment = '', int level = 0) {
|
||||
def results = [
|
||||
'metacollection' : metacollection,
|
||||
'comment': comment
|
||||
]
|
||||
results.metacollection.add(this)
|
||||
results.comment += "${level} ".padRight(level * 4) + globalreleasetag() + '\n'
|
||||
for (relatedmetainfo in associatedmeta) {
|
||||
if (!relatedmetainfo.format || relatedmetainfo.format == '0.1') {
|
||||
def MetaInfo othermeta = relatedmetainfo.meta
|
||||
results = othermeta.walkrelated_v0_1(results.metacollection, results.comment, level + 1)
|
||||
} else {
|
||||
script.error("There is non v0.1 format related meta info under v0.1 related meta info")
|
||||
}
|
||||
}
|
||||
return [ 'metacollection' : results.metacollection, 'comment': results.comment ]
|
||||
}
|
||||
|
||||
def walkrelated(ArrayList<MetaInfo> metacollection, String comment = '', int level = 0, String gatheredpath = '') {
|
||||
def results = [
|
||||
'metacollection' : metacollection,
|
||||
|
|
@ -960,9 +1020,14 @@ class MetaInfo extends GISJsonSerialised {
|
|||
results.metacollection.add(this)
|
||||
results.comment += "${level} ".padRight(level * 4) + globalreleasetag() + '\n'
|
||||
for (relatedmetainfo in associatedmeta) {
|
||||
def childmetainfo = openchildmeta(gatheredpath, relatedmetainfo)
|
||||
if (childmetainfo.imported) {
|
||||
results = childmetainfo.childmeta.walkrelated(results.metacollection, results.comment, level + 1, childmetainfo.nextpath)
|
||||
if (relatedmetainfo.format == '0.2') {
|
||||
def childmetainfo = openchildmeta(gatheredpath, relatedmetainfo)
|
||||
if (childmetainfo.imported) {
|
||||
results = childmetainfo.childmeta.walkrelated(results.metacollection, results.comment, level + 1, childmetainfo.nextpath)
|
||||
}
|
||||
} else if (relatedmetainfo.format == '0.1') {
|
||||
def MetaInfo othermeta = relatedmetainfo.meta
|
||||
results = othermeta.walkrelated_v0_1(results.metacollection, results.comment, level + 1)
|
||||
}
|
||||
}
|
||||
return [ 'metacollection' : results.metacollection, 'comment': results.comment ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue