comparison init20-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 131275ef326a
children 64a8d53c6d98
comparison
equal deleted inserted replaced
330:70ea30cbe883 331:7bc7c6c79d7c
830 println "git pull $repositoryUrl".execute().text 830 println "git pull $repositoryUrl".execute().text
831 } 831 }
832 def versions = "git tag".execute().text.split("\n") 832 def versions = "git tag".execute().text.split("\n")
833 .findAll { it != null || it != "" } 833 .findAll { it != null || it != "" }
834 .collect { it.replace("v", "") } 834 .collect { it.replace("v", "") }
835 .collect {
836 Version v = null
837 try {
838 v = new Version(*it.split('\\.')*.toInteger())
839 return v
840 } catch (ignored) {
841 //non semver tag found, ignoring
842 }
843 }
844 .sort { v1, v2 -> v2 <=> v1 }
845
846 def branches = "git branch --remote".execute().text.split("\n")
847 .findAll { it.contains('release') || it.contains('hotfix') }
848 .collect { it.replaceAll('\\s+', ' ').split(' ')[1].split('/')[2] - 'v' }
835 .collect { new Version(*it.split('\\.')*.toInteger()) } 849 .collect { new Version(*it.split('\\.')*.toInteger()) }
836 .sort { v1, v2 -> v2 <=> v1 } 850
837 return versions ? versions.first().nextSnapshot() : new Version().nextSnapshot() 851 def results = (branches + versions).sort { v1, v2 -> v2 <=> v1 }
852 if (results.isEmpty()) {
853 return new Version().nextSnapshot()
854 } else {
855 return results.first().nextSnapshot()
856 }
838 } catch (ex) { 857 } catch (ex) {
839 println ex 858 println ex
840 return new Version().nextSnapshot() 859 return new Version().nextSnapshot()
841 } 860 }
842 } 861 }