changeset 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 131275ef326a
children def784e473ec
files init40-git.gradle
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/init40-git.gradle	Thu Feb 09 14:24:44 2023 -0500
+++ b/init40-git.gradle	Fri Feb 17 12:06:01 2023 -0500
@@ -798,9 +798,22 @@
             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())
+                        } catch (ignored) {
+                            println "non semver tag found, ignoring"
+                            //non semver tag found, ignoring
+                        }
+                    }
+                    .findAll { it != null }
                     .sort { v1, v2 -> v2 <=> v1 }
-            return versions ? versions.first().nextSnapshot() : new Version().nextSnapshot()
+            if (versions.isEmpty()) {
+                return new Version().nextSnapshot()
+            } else {
+                return versions.first().nextSnapshot()
+            }
         } catch (ex) {
             println ex
             return new Version().nextSnapshot()