summary refs log tree commit diff
path: root/xrevbump
blob: a46c2cf2ff3ada12b571a5cd11856a95965b7972 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# xrevbump MESSAGE TEMPLATES... - increase template revision and commit

# TEMPLATES can be "-", then read linewise from stdin.

MESSAGE=$1
shift

if [ $# -eq 0 ]; then
	printf "Usage: xrevbump MESSAGE TEMPLATES...\n" 2>&1
        exit 1
fi

seen=' '
nl='
'

bump() {
	t="$1"
	if [ -f "$t" ]; then
		:
	elif [ -f "$t/template" ]; then
		t="$t/template"
	elif [ -f "srcpkgs/$t/template" ]; then
		t="srcpkgs/$t/template"
	else
		printf "Cannot find template '%s'\n" "$t"
		break
	fi

	. "$t"

	case "$seen" in
	*" $pkgname "*)
		printf "%s: bumped already.\n" "$t"
		;;
	*)
		revision=$((revision + 1))
		printf "%s: bump to revision %d\n" "$t" "$revision"

		sed -i -e "/^revision=/s/=.*/=$revision/" "$t"
		git -C "${t%/*}" commit -m "$pkgname: $MESSAGE" template
		seen="$seen $pkgname "
		;;
	esac
}

if [ "$1" = - ]; then
	while IFS="$nl" read -r t; do
		bump "$t"
	done
else
	for t; do
		bump "$t"
	done
fi