comparison init40-git.gradle @ 331:7bc7c6c79d7c

check for current release and hotfix branches when looking for latest snapshot
author Marc Davis <davis@ssdt-ohio.org>
date Mon, 06 Mar 2023 13:37:28 -0500
parents 1a7daef79467
children ae546c35dee4
comparison
equal deleted inserted replaced
330:70ea30cbe883 331:7bc7c6c79d7c
800 .collect { it.replace("v", "") } 800 .collect { it.replace("v", "") }
801 .collect { 801 .collect {
802 Version v = null 802 Version v = null
803 try { 803 try {
804 v = new Version(*it.split('\\.')*.toInteger()) 804 v = new Version(*it.split('\\.')*.toInteger())
805 return v
805 } catch (ignored) { 806 } catch (ignored) {
806 println "non semver tag found, ignoring"
807 //non semver tag found, ignoring 807 //non semver tag found, ignoring
808 } 808 }
809 } 809 }
810 .findAll { it != null } 810 .findAll { it != null }
811 .sort { v1, v2 -> v2 <=> v1 } 811 .sort { v1, v2 -> v2 <=> v1 }
812 if (versions.isEmpty()) { 812
813 def branches = "git branch --remote".execute().text.split("\n")
814 .findAll { it.contains('release') || it.contains('hotfix') }
815 .collect { it.replaceAll('\\s+', ' ').split(' ')[1].split('/')[2] - 'v' }
816 .collect { new Version(*it.split('\\.')*.toInteger()) }
817
818 def results = (branches + versions).sort { v1, v2 -> v2 <=> v1 }
819 if (results.isEmpty()) {
813 return new Version().nextSnapshot() 820 return new Version().nextSnapshot()
814 } else { 821 } else {
815 return versions.first().nextSnapshot() 822 return results.first().nextSnapshot()
816 } 823 }
817 } catch (ex) { 824 } catch (ex) {
818 println ex 825 println ex
819 return new Version().nextSnapshot() 826 return new Version().nextSnapshot()
820 } 827 }