Supply release tag processing

This commit is contained in:
Dan Hawkins 2022-02-25 07:56:28 +00:00
commit 44b1e13f31

View file

@ -1,5 +1,5 @@
LinkedHashMap RELEASETAG_PREFIXES = [
def LinkedHashMap RELEASETAG_PREFIXES = [
'superceded' : 'Misspelt - Indicates a later release has superseded the release with this prefix',
'superseded' : 'Indicates a later release has superseded the release with this prefix',
'erroneous' : 'The release was released unintentionally',
@ -8,33 +8,29 @@ LinkedHashMap RELEASETAG_PREFIXES = [
'inmainline' : 'This release was associated with development branch which has now been merged into mainline',
]
RELEASETAG_PREFIX_SEPERATOR = '_'
def RELEASETAG_PREFIX_SEPERATOR = '_'
def startswithspecialprefix(String releasetag) {
def boolean hasspecialprefix = false
def String releasetagprefix = ''
def String prefixfound = ''
def String prefixmeaning = ''
def String tagwithoutprefix = releasetag
echo "Release tag is: ${releasetag}"
// Two forms of releasetag expected
// <prefix>_<version>_<buildnumber>
// <version>_<buildnumber>
def int separatorcount = releasetag.split(RELEASETAG_PREFIX_SEPERATOR).size() - 1
echo "separatorcount is: ${separatorcount}"
def firstseperatorindex = releasetag.indexOf(RELEASETAG_PREFIX_SEPERATOR)
echo "firstseperatorindex is: ${firstseperatorindex}"
if (separatorcount >= 2) {
if (firstseperatorindex > 0) {
prefixfound = releasetag[0..(firstseperatorindex - 1)].toLowerCase()
hasspecialprefix = RELEASETAG_PREFIXES.containsKey(prefixfound)
tagwithoutprefix = releasetag[(firstseperatorindex + 1)..-1]
RELEASETAG_PREFIXES.each { prefix, meaning ->
if (releasetag.toLowerCase().startsWith(prefix)) {
prefixfound = prefix
hasspecialprefix = true
prefixmeaning = meaning
tagwithoutprefix = releasetag[(prefix.size() + 1)..-1]
break
}
}
echo "Results are: ${hasspecialprefix} ${prefixfound} ${tagwithoutprefix}"
return [ 'hasspecialprefix' : hasspecialprefix,
'prefixfound' : prefixfound,
'tagwithoutprefix' : tagwithoutprefix,
'meaning' : prefixmeaning,
]
}