comparison init50-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 729ee03ee479
children 64a8d53c6d98
comparison
equal deleted inserted replaced
330:70ea30cbe883 331:7bc7c6c79d7c
795 println "git pull $repositoryUrl".execute().text 795 println "git pull $repositoryUrl".execute().text
796 } 796 }
797 def versions = "git tag".execute().text.split("\n") 797 def versions = "git tag".execute().text.split("\n")
798 .findAll { it != null || it != "" } 798 .findAll { it != null || it != "" }
799 .collect { it.replace("v", "") } 799 .collect { it.replace("v", "") }
800 .collect {
801 Version v = null
802 try {
803 v = new Version(*it.split('\\.')*.toInteger())
804 return v
805 } catch (ignored) {
806 //non semver tag found, ignoring
807 }
808 }
809 .sort { v1, v2 -> v2 <=> v1 }
810
811 def branches = "git branch --remote".execute().text.split("\n")
812 .findAll { it.contains('release') || it.contains('hotfix') }
813 .collect { it.replaceAll('\\s+', ' ').split(' ')[1].split('/')[2] - 'v' }
800 .collect { new Version(*it.split('\\.')*.toInteger()) } 814 .collect { new Version(*it.split('\\.')*.toInteger()) }
801 .sort { v1, v2 -> v2 <=> v1 } 815
802 return versions ? versions.first().nextSnapshot() : new Version().nextSnapshot() 816 def results = (branches + versions).sort { v1, v2 -> v2 <=> v1 }
817 if (results.isEmpty()) {
818 return new Version().nextSnapshot()
819 } else {
820 return results.first().nextSnapshot()
821 }
803 } catch (ex) { 822 } catch (ex) {
804 println ex 823 println ex
805 return new Version().nextSnapshot() 824 return new Version().nextSnapshot()
806 } 825 }
807 } 826 }