#!/bin/bash
# handy wrapper for 'git commit', prepending package name

args=()
msg=

# check for -m ...
while [[ ${#} -gt 0 ]]; do
	if [[ ${1} == -m ]]; then
		msg=${2}
		shift 2
		continue
	fi

	args+=( "${1}" )
	shift
done

set -e -x

tmpf=$(mktemp)
echo "$(pkg): ${msg}" > "${tmpf}"
[[ ${msg} ]] || "${EDITOR:-vim}" "${tmpf}"
if [[ -s ${tmpf} ]]; then
	git commit -F "${tmpf}" "${args[@]}"
fi
rm -f "${tmpf}"
