summaryrefslogtreecommitdiff
path: root/pbs-package-commit
blob: 54e944fdb3ebac4d8b4f558a5ab5d242ea308304 (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
36
37
38
39
40
41
#!/bin/bash -euE

. $(which libremessages)

cmd=${0##*/}
usage() {
	echo "Usage: $cmd [git-commit OPTIONS]"
	echo 'Commits to a package (run from the package directory).'
	echo ''
	echo 'This is the same as `git commit`, but cascades up out of the'
	echo 'submodule.'
	echo ''
	echo 'Options:'
	echo '  -h            Show this message'
	echo ''
	echo ' ====================== `git commit` usage ======================'
	echo ''
	git commit -h
}

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

	if [[ ! -f .git ]]; then
		error "Must be in a package directory"
		return 1
	fi

	git commit "$@"
	git push
	local msg="$(git log -n1 --pretty=format:%B)"
	local dir="$(pwd)"
	cd ..
	git add "${dir##*/}"
	git commit -m "$msg"
}

main "$@"