We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f4145fa commit f7e23f8Copy full SHA for f7e23f8
1 file changed
semver-get-pointrelease.sh
@@ -0,0 +1,26 @@
1
+#!/usr/bin/env bash
2
+# Search a list of local git tags for the "latest" matching the input argument.
3
+# Input must be in the form of: x.y
4
+# Can't rely on `sort -V` since it requires GNU coreutils.
5
+
6
+if [ -z $1 ]; then
7
+ exit 1
8
+fi
9
10
+if [ -z $2 ]; then
11
+ REPO_DIR=.
12
+else
13
+ REPO_DIR=$2
14
15
16
+git --work-tree="$REPO_DIR" --git-dir="$REPO_DIR/.git" tag -l 1>&2
17
18
+MAJOR_MINOR=$1
19
+POINTRELEASE=$( git --work-tree="$REPO_DIR" --git-dir="$REPO_DIR/.git" tag -l | grep "^$MAJOR_MINOR" | sed "s/$MAJOR_MINOR\.//" | sort -n | tail -1 )
20
21
22
+if [ -z $POINTRELEASE ]; then
23
+ exit 2
24
25
26
+echo "$MAJOR_MINOR.$POINTRELEASE"
0 commit comments