Perform a deep copy of version objects

This commit is contained in:
Dan Hawkins 2021-11-09 12:07:09 +00:00
commit e8ea9a2932
2 changed files with 22 additions and 2 deletions

View file

@ -108,6 +108,15 @@ class GitInfo extends GISJsonSerialised {
this.remoteinfo = remoteinfo
}
GitInfo(GitInfo another) {
super(another.script)
this.sourcepath = another.sourcepath
this.sourcerevision = another.sourcerevision
this.gitrevision = another.gitrevision
this.remoteurl = another.remoteurl
this.remoteinfo = another.remoteinfo
}
void set(String sourcepath, String sourcerevision, String gitrevision, String remoteurl, String remoteinfo) {
this.sourcepath = sourcepath
this.sourcerevision = sourcerevision
@ -267,6 +276,13 @@ class BuildStampInfo extends GISJsonSerialised {
this.buildstamp = buildstamp
}
BuildStampInfo(BuildStampInfo another) {
super(another.script)
this.buildstampprefix = another.buildstampprefix
this.revision = another.revision
this.buildstamp = another.buildstamp
}
void set(String buildstampprefix, int revision, String buildstamp) {
this.buildstampprefix = buildstampprefix
this.revision = revision

View file

@ -160,8 +160,12 @@ String generate(meta, String sourcerevision, String sourcepath, String basebuild
}
String copyfrom(meta, othermeta) {
meta.gitinfo = othermeta.gitinfo
meta.buildstampinfo = othermeta.buildstampinfo
// Deep copy
def newgitinfo = othermeta.gitinfo.getClass().newInstance(othermeta.gitinfo)
def newbuildstampinfo = othermeta.buildstampinfo.getClass().newInstance(othermeta.buildstampinfo)
meta.gitinfo = newgitinfo
meta.buildstampinfo = newbuildstampinfo
return meta.buildstampinfo.buildstamp
}