#!/bin/bash
+# sunrise-commit - Automates the Gentoo Sunrise Overlay commit process
+# Released into the public domain
# $Id$
source /sbin/functions.sh
+BLUE=$BRACKET
BOLD=$'\e[0;01m'
-GREEN=$'\e[32m'
-
-changelog=0
-disable_repoman=0
-force=0
-noupdate=0
-quiet=0
-verbose=0
+DARKGREEN=$'\e[32m'
+GREEN=$GOOD
+LIGHTBLUE=$HILITE
+MSG_NEW_EBUILD="New Ebuild"
+MSG_PATCH="Patch"
+MSG_REVISION_BUMP="Revision Bump"
+MSG_VERSION_BUMP="Version Bump"
+RED=$BAD
+YELLOW=$WARN
+
+commit_category=$(echo `pwd` | awk -F/ '{ print $(NF-1) }')
+commit_message="moo"
+commit_package=$(echo `pwd` | awk -F/ '{ print $NF }')
+commit_status="$(echo `svn status`)"
+opt_changelog=0
+opt_disable_repoman=0
+opt_force=0
+opt_noupdate=0
+opt_quiet=0
+opt_verbose=0
changelog_append() {
- if [[ "$changelog" == "1" ]] ; then
+ if [[ "$opt_changelog" == "1" ]] ; then
ebegin "Appending/creating ChangeLog"
echangelog "$1"
eend $?
}
create_digests() {
- if [[ "$force" == "0" ]] ; then
+ if [[ "$opt_force" == "0" ]] ; then
if [[ ! $(find *.ebuild -maxdepth 0) ]] ; then
echo "!!! Error: No ebuilds found in current directory. Use -f to force commit."
exit 1
fi
}
+format_message() {
+ commit_status="$(echo `svn status`)"
+ if [[ "$commit_status" =~ '\.ebuild' ]] ; then
+ commit_message="${commit_category}/${commit_package}: $*"
+ else
+ commit_message="${commit_package}/$(echo $commit_status | awk '{ print $2 }'): $*"
+ fi
+}
+
repoman_check() {
- if [[ "$disable_repoman" == "0" ]] ; then
+ if [[ "$opt_disable_repoman" == "0" ]] ; then
ebegin "Running repoman"
PORTDIR_OVERLAY=$(dirname $(dirname $(pwd)))
export PORTDIR_OVERLAY
svn_add() {
ebegin "Adding local changes to working copy"
- if [[ "$verbose" == "1" ]] ; then
+ if [[ "$opt_verbose" == "1" ]] ; then
svn add *
else
svn add -q *
svn_commit() {
echo
- echo "${GREEN}The following local changes will be committed to the repository:${NORMAL}"
+ echo "${DARKGREEN}The following local changes will be committed to the repository:${NORMAL}"
echo
svn status
+ echo
+ echo "${DARKGREEN}The following commit message will be used:${NORMAL}"
+ echo
+ echo "$*"
- if [[ "$quiet" == "0" ]] ; then
+ if [[ "$opt_quiet" == "0" ]] ; then
echo
- echo -n "${BOLD}Commit changes?${NORMAL} [${GOOD}Yes${NORMAL}/${BAD}No${NORMAL}] "
+ echo -n "${BOLD}Commit changes?${NORMAL} [${GREEN}Yes${NORMAL}/${RED}No${NORMAL}] "
read choice
echo
}
svn_up() {
- if [[ "$noupdate" == "0" ]] ; then
+ if [[ "$opt_noupdate" == "0" ]] ; then
ebegin "Updating working copy to latest version from repository"
- if [[ "$verbose" == "1" ]] ; then
+ if [[ "$opt_verbose" == "1" ]] ; then
svn update
else
svn update -q
usage() {
cat << EOF
-${BOLD}Usage:${NORMAL} ${HILITE}sunrise-commit${NORMAL} [ ${GOOD}options${NORMAL} ] ${BRACKET}message${NORMAL}
+${BOLD}Usage:${NORMAL} ${HILITE}sunrise-commit${NORMAL} [ ${GREEN}options${NORMAL} ] ${BLUE}message${NORMAL}
-${GOOD}options${NORMAL} are:
- ${BOLD}-c, --changelog${NORMAL} Create a ChangeLog entry using ${BRACKET}message${NORMAL}
+${GREEN}options${NORMAL} are:
+ ${BOLD}-c, --changelog${NORMAL} Create a ChangeLog entry using ${BLUE}message${NORMAL}
${BOLD}-d, --disable-repoman${NORMAL} Skip repoman check
${BOLD}-f, --force${NORMAL} Commit even if no ebuilds are present
${BOLD}-h, --help${NORMAL} Show help
${BOLD}-q, --quiet${NORMAL} Don't ask for confirmation
${BOLD}-v, --verbose${NORMAL} Show more detailed information during commit
-${BRACKET}message${NORMAL} is:
- Commit message describing changes made. ${BOLD}Please include the ebuild's name here.${NORMAL}
- For ebuild updates the suggested message format is:
-
- "${WARN}categoryname${NORMAL}/${WARN}packagename${NORMAL}: ${WARN}List of changes${NORMAL}. Thanks to ${WARN}list of contributors${NORMAL}."
-
- For new ebuilds, prefix the above message with:
-
- "[New ebuild] Bug ${WARN}Gentoo bug #${NORMAL}, "
+${BLUE}message${NORMAL} is:
+ Commit message describing changes and listing names/emails of anyone (other
+ than the commiter) who contributed.
EOF
exit ${1:-0}
}
echo "!!! export ECHANGELOG_USER=\"Your Name <your@mail.org>\""
exit 1
fi
- changelog=1
+ opt_changelog=1
shift ;;
--disable-repoman|-d)
- disable_repoman=1
+ opt_disable_repoman=1
shift ;;
--force|-f)
- force=1
+ opt_force=1
shift ;;
--help|-h)
usage ;;
--noupdate|-n)
- noupdate=1
+ opt_noupdate=1
shift ;;
--quiet|-q)
- quiet=1
+ opt_quiet=1
shift ;;
--verbose|-v)
- verbose=1
+ opt_verbose=1
shift ;;
-*)
exit 1
fi
-if [[ -z "$(echo `svn status`)" ]] ; then
- ewarn "No changes found in current directory."
+if [[ -z "$commit_status" ]] ; then
+ ewarn "No changes found in current directory tree."
exit 1
fi
changelog_append "$1" || exit $?
svn_add || exit $?
#repoman_check || exit $?
-svn_commit "$*" || exit $?
+format_message "$*"
+svn_commit "$commit_message" || exit $?