summaryrefslogtreecommitdiff
path: root/pbs-package-postcommit
blob: 0a02af717b6cad79e09bdefe240d1ff464b3df06 (plain)
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
#!/bin/bash -euE

. pbs-plumb-shlib

cmd=${0##*/}
usage() {
	echo "Usage: $cmd [git-commit OPTIONS]"
	echo 'Call after doing a `git commit` manually. (from pkg dir)'
	echo
	echo 'This cascades the commit up out of the submodule.'
	echo
	echo 'Options:'
	echo '  -h            Show this message'
}

main() {
	if in_array '-h' "$@"; then
		usage
		return 0
	fi

	ensure_in_pbs-package

	# push the commit upstream
	git push -f origin "$(gitbranch)"

	# update the submodule
	local msg="$(git log -n1 --pretty=format:%B)"
	local dir="$(pwd)"
	cdto_pbs-root
	git add "$dir"
	git commit -m "$msg"
}

main "$@"