aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/git/.local/bin/git-bump
diff options
context:
space:
mode:
Diffstat (limited to 'git/.local/bin/git-bump')
-rwxr-xr-xgit/.local/bin/git-bump27
1 files changed, 27 insertions, 0 deletions
diff --git a/git/.local/bin/git-bump b/git/.local/bin/git-bump
new file mode 100755
index 0000000..d75a755
--- /dev/null
+++ b/git/.local/bin/git-bump
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+tag="$(git describe --abbrev=0 2>/dev/null)"
+IFS=. read -r major minor patch <<EOF
+${tag#v}
+EOF
+
+case "$1" in
+major)
+ major=$((major + 1))
+ minor=0
+ patch=0
+ ;;
+minor)
+ minor=$((minor + 1))
+ patch=0
+ ;;
+patch)
+ patch=$((patch + 1))
+ ;;
+*)
+ echo "Invalid semver argument given (major|minor|patch): $1" 1>&2
+ exit 1
+ ;;
+esac
+
+git shortlog "$tag"..HEAD | git tag -s "v${major}.${minor}.${patch}" --file -