summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2021-11-02 18:38:24 +0100
committerRobert Günzler <r@gnzler.io>2021-11-02 19:06:51 +0100
commit4ed462aa5278bfa0d6d94e2ca822170ad845d04e (patch)
tree85516cdc2211401f199ea2249a465895c1246921
parentca57f33713ad4b466668f214445abe5ab5a771f5 (diff)
bin: add git-commit-bump
-rwxr-xr-xbin/git-commit-bump43
1 files changed, 43 insertions, 0 deletions
diff --git a/bin/git-commit-bump b/bin/git-commit-bump
new file mode 100755
index 0000000..e3e3300
--- /dev/null
+++ b/bin/git-commit-bump
@@ -0,0 +1,43 @@
+#!/bin/bash
+set -e
+[ -n "$DEBUG" ] && set -x
+
+if [ "$1" = "-h" ]; then
+	echo "usage: $(basename "${0}") DEPENDENCY [from] TO"
+	echo
+	exit 0
+fi
+
+dependency=$1
+from=$2
+to=$3
+
+if [ -z "${dependency}" ]; then
+	echo "error: missing dependency to bump, see -h" >&2
+	exit 1
+fi
+
+if [ -z "${to}" ]; then
+	to=$from
+	from=$(git log --format=%b | awk "{ if(match(\$0,/[Uu]pdate ${dependency} from (.+) to (.+)$/,m)) print(m[2]); exit(0) }")
+	if [ -z "${from}" ]; then
+		# still no $from, let's give the user a choice using fzf
+		from=$(git log --format=%b | awk "{ if(match(\$0,/[Uu]pdate (.+) from (.+) to (.+)$/,m)) print m[0] }" | fzf | sed 's#.*to \(.*\)$#\1#')
+	fi
+fi
+
+if [ -z "${to}" ]; then
+	echo "error: missing version to bump to, see -h" >&2
+	exit 1
+fi
+
+git commit --edit --file <(
+	cat <<-EOF
+		Update ${dependency} to ${to}
+
+		Update ${dependency} from ${from} to ${to}
+
+		Change-type: patch
+		Signed-off-by: $(git config user.name) $(git config user.signemail || git config user.email)
+	EOF
+)