Mercurial > public > develkit
changeset 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 | 70ea30cbe883 |
children | ae546c35dee4 |
files | init20-git.gradle init40-git.gradle init50-git.gradle init70-git.gradle |
diffstat | 4 files changed, 73 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/init20-git.gradle Fri Mar 03 22:02:56 2023 -0500 +++ b/init20-git.gradle Mon Mar 06 13:37:28 2023 -0500 @@ -832,9 +832,28 @@ def versions = "git tag".execute().text.split("\n") .findAll { it != null || it != "" } .collect { it.replace("v", "") } - .collect { new Version(*it.split('\\.')*.toInteger()) } + .collect { + Version v = null + try { + v = new Version(*it.split('\\.')*.toInteger()) + return v + } catch (ignored) { + //non semver tag found, ignoring + } + } .sort { v1, v2 -> v2 <=> v1 } - return versions ? versions.first().nextSnapshot() : new Version().nextSnapshot() + + def branches = "git branch --remote".execute().text.split("\n") + .findAll { it.contains('release') || it.contains('hotfix') } + .collect { it.replaceAll('\\s+', ' ').split(' ')[1].split('/')[2] - 'v' } + .collect { new Version(*it.split('\\.')*.toInteger()) } + + def results = (branches + versions).sort { v1, v2 -> v2 <=> v1 } + if (results.isEmpty()) { + return new Version().nextSnapshot() + } else { + return results.first().nextSnapshot() + } } catch (ex) { println ex return new Version().nextSnapshot()
--- a/init40-git.gradle Fri Mar 03 22:02:56 2023 -0500 +++ b/init40-git.gradle Mon Mar 06 13:37:28 2023 -0500 @@ -802,17 +802,24 @@ Version v = null try { v = new Version(*it.split('\\.')*.toInteger()) + return v } catch (ignored) { - println "non semver tag found, ignoring" //non semver tag found, ignoring } } .findAll { it != null } .sort { v1, v2 -> v2 <=> v1 } - if (versions.isEmpty()) { + + def branches = "git branch --remote".execute().text.split("\n") + .findAll { it.contains('release') || it.contains('hotfix') } + .collect { it.replaceAll('\\s+', ' ').split(' ')[1].split('/')[2] - 'v' } + .collect { new Version(*it.split('\\.')*.toInteger()) } + + def results = (branches + versions).sort { v1, v2 -> v2 <=> v1 } + if (results.isEmpty()) { return new Version().nextSnapshot() } else { - return versions.first().nextSnapshot() + return results.first().nextSnapshot() } } catch (ex) { println ex
--- a/init50-git.gradle Fri Mar 03 22:02:56 2023 -0500 +++ b/init50-git.gradle Mon Mar 06 13:37:28 2023 -0500 @@ -797,9 +797,28 @@ def versions = "git tag".execute().text.split("\n") .findAll { it != null || it != "" } .collect { it.replace("v", "") } - .collect { new Version(*it.split('\\.')*.toInteger()) } + .collect { + Version v = null + try { + v = new Version(*it.split('\\.')*.toInteger()) + return v + } catch (ignored) { + //non semver tag found, ignoring + } + } .sort { v1, v2 -> v2 <=> v1 } - return versions ? versions.first().nextSnapshot() : new Version().nextSnapshot() + + def branches = "git branch --remote".execute().text.split("\n") + .findAll { it.contains('release') || it.contains('hotfix') } + .collect { it.replaceAll('\\s+', ' ').split(' ')[1].split('/')[2] - 'v' } + .collect { new Version(*it.split('\\.')*.toInteger()) } + + def results = (branches + versions).sort { v1, v2 -> v2 <=> v1 } + if (results.isEmpty()) { + return new Version().nextSnapshot() + } else { + return results.first().nextSnapshot() + } } catch (ex) { println ex return new Version().nextSnapshot()
--- a/init70-git.gradle Fri Mar 03 22:02:56 2023 -0500 +++ b/init70-git.gradle Mon Mar 06 13:37:28 2023 -0500 @@ -792,9 +792,28 @@ def versions = "git tag".execute().text.split("\n") .findAll { it != null || it != "" } .collect { it.replace("v", "") } - .collect { new Version(*it.split('\\.')*.toInteger()) } + .collect { + Version v = null + try { + v = new Version(*it.split('\\.')*.toInteger()) + return v + } catch (ignored) { + //non semver tag found, ignoring + } + } .sort { v1, v2 -> v2 <=> v1 } - return versions ? versions.first().nextSnapshot() : new Version().nextSnapshot() + + def branches = "git branch --remote".execute().text.split("\n") + .findAll { it.contains('release') || it.contains('hotfix') } + .collect { it.replaceAll('\\s+', ' ').split(' ')[1].split('/')[2] - 'v' } + .collect { new Version(*it.split('\\.')*.toInteger()) } + + def results = (branches + versions).sort { v1, v2 -> v2 <=> v1 } + if (results.isEmpty()) { + return new Version().nextSnapshot() + } else { + return results.first().nextSnapshot() + } } catch (ex) { println ex return new Version().nextSnapshot()