comparison init40-git.gradle @ 327:1a7daef79467

handle non semver tags and ignore
author Marc Davis <davis@ssdt-ohio.org>
date Fri, 17 Feb 2023 12:06:01 -0500
parents a49456faf505
children 7bc7c6c79d7c
comparison
equal deleted inserted replaced
326:131275ef326a 327:1a7daef79467
796 println "git pull $repositoryUrl".execute().text 796 println "git pull $repositoryUrl".execute().text
797 } 797 }
798 def versions = "git tag".execute().text.split("\n") 798 def versions = "git tag".execute().text.split("\n")
799 .findAll { it != null || it != "" } 799 .findAll { it != null || it != "" }
800 .collect { it.replace("v", "") } 800 .collect { it.replace("v", "") }
801 .collect { new Version(*it.split('\\.')*.toInteger()) } 801 .collect {
802 Version v = null
803 try {
804 v = new Version(*it.split('\\.')*.toInteger())
805 } catch (ignored) {
806 println "non semver tag found, ignoring"
807 //non semver tag found, ignoring
808 }
809 }
810 .findAll { it != null }
802 .sort { v1, v2 -> v2 <=> v1 } 811 .sort { v1, v2 -> v2 <=> v1 }
803 return versions ? versions.first().nextSnapshot() : new Version().nextSnapshot() 812 if (versions.isEmpty()) {
813 return new Version().nextSnapshot()
814 } else {
815 return versions.first().nextSnapshot()
816 }
804 } catch (ex) { 817 } catch (ex) {
805 println ex 818 println ex
806 return new Version().nextSnapshot() 819 return new Version().nextSnapshot()
807 } 820 }
808 } 821 }