Sfoglia il codice sorgente

Improve git-flow-release function to detect lastag and increment it by its own

Emmanuel Bouthenot 7 anni fa
parent
commit
8285e46aaa
1 ha cambiato i file con 14 aggiunte e 3 eliminazioni
  1. 14 3
      .zsh/config/10_alias.zsh

+ 14 - 3
.zsh/config/10_alias.zsh

@@ -181,10 +181,21 @@ fi
 # Git Flow stuff
 #
 git-flow-release() {
-    if [[ "${1}" != "" ]]; then
+    local version_next=""
+    if [[ "${1}" = "" ]]; then
+        local version_current="$(git lasttag 2>/dev/null)"
+        if [[ "${version_current}" != "" ]]; then
+            local version_minor="${version_current##*.}"
+            local version_major="${version_current%.*}"
+            local version_next="${version_major}.$((version_minor+1))"
+        fi
+    else
+        version_next="${1}"
+    fi
+    if [[ "${version_next}" != "" ]]; then
         export GIT_MERGE_AUTOEDIT=no
-        git flow release start "${1}" && \
-            GIT_MERGE_AUTOEDIT=no git flow release finish -m "${1}" "${1}"
+        git flow release start "${version_next}" && \
+            GIT_MERGE_AUTOEDIT=no git flow release finish -m "${version_next}" "${version_next}"
     else
         printf "%s: tag is missing\n" "${0}" >&2
     fi