2 # sunrise-commit - Automates the Gentoo Sunrise Overlay commit process
3 # Released into the public domain
5 source /sbin/functions.sh
15 commit_category="$(pwd | awk -F/ '{ print $(NF-1) }')"
16 commit_package="$(pwd | awk -F/ '{ print $NF }')"
26 if [[ "$opt_changelog" == "1" ]] ; then
27 if [[ "$(svn status)" =~ 'ChangeLog' ]] ; then
28 echo "!!! Error: Only one ChangeLog entry should be made per commit, and you have"
29 echo "!!! already modified your ChangeLog locally since your last commit. To keep the"
30 echo "!!! pre-existing modifications please run sunrise-commit again without the -c"
31 echo "!!! option. To discard the pre-existing modifications run:"
32 echo "!!! svn revert ChangeLog"
35 ebegin "Appending/creating ChangeLog"
42 if [[ "$(ls)" =~ '\.ebuild' ]] ; then
43 ebegin "Digesting ebuilds"
44 for i in *.ebuild ; do
53 if [[ "$opt_norepoman" == "0" ]] ; then
54 if [[ "$(ls)" =~ '\.ebuild' ]] ; then
55 ebegin "Running repoman"
56 export PORTDIR_OVERLAY="$(dirname $(dirname $(pwd)))"
65 ebegin "Adding local changes to working copy"
66 if [[ "$opt_verbose" == "1" ]] ; then
67 svn add ../$(basename `pwd`) --force
69 svn add ../$(basename `pwd`) --force -q
75 local commit_message="$*"
77 for (( i=num_new_dirs ; i > 0 ; i-- )) ; do
81 if [[ "$opt_noformat" == "0" ]] ; then
82 if [[ "$(ls)" =~ '\.ebuild' ]] ; then
83 commit_message="${commit_category}/${commit_package}: ${commit_message}"
85 commit_message="${commit_package}/$(svn status | awk '{ print $2 }'): ${commit_message}"
90 echo "${DARKGREEN}The following local changes will be committed to the repository:${NORMAL}"
94 echo "${DARKGREEN}The following commit message will be used:${NORMAL}"
96 echo "$commit_message"
98 if [[ "$opt_quiet" == "0" ]] ; then
100 echo -n "${BOLD}Commit changes?${NORMAL} [${GREEN}Yes${NORMAL}/${RED}No${NORMAL}] "
115 ebegin "Committing working copy to repository"
116 svn commit -m "$commit_message"
121 if [[ "$opt_noupdate" == "0" ]] ; then
122 while [[ "$(echo `svn status`)" =~ 'A.+? \.' ]] ; do
127 ebegin "Updating working copy to latest version from repository"
129 if [[ "$opt_verbose" == "1" ]] ; then
132 svn update -q || set $?
137 for (( i=num_new_dirs ; i > 0 ; i-- )) ; do
141 local conflict_files=$(svn status | sed -rn 's/^C.+ ([^ ]+)$/\1/p')
142 if [[ -n "$conflict_files" ]] ; then
143 echo "!!! Error: Some local files have changes that conflict with the latest"
144 echo "!!! revisions in the repository. Please contact the previous committer(s) to"
145 echo "!!! resolve the conflicts manually before running sunrise-commit again:"
146 for filename in $conflict_files ; do
148 echo "!!! file: ${filename}"
149 echo "!!! committer: $(svn info ${filename} | sed -rn 's/Last Changed Author\: (.*)$/\1/p')"
159 ${BOLD}Usage:${NORMAL} ${LIGHTBLUE}sunrise-commit${NORMAL} [ ${GREEN}options${NORMAL} ] ${BLUE}message${NORMAL}
161 ${GREEN}options${NORMAL}:
162 ${BOLD}--changelog, -c${NORMAL} Create a ChangeLog entry using ${BLUE}message${NORMAL}
163 ${BOLD}--help, -h${NORMAL} Show help
164 ${BOLD}--noformat, -m${NORMAL} Disable automatic formatting of ${BLUE}message${NORMAL}
165 ${BOLD}--norepoman, -p${NORMAL} Skip repoman check
166 ${BOLD}--noupdate, -d${NORMAL} Don't update from repository before committing
167 ${BOLD}--quiet, -q${NORMAL} Don't ask for confirmation
168 ${BOLD}--verbose, -v${NORMAL} Show detailed information during commit
170 ${BLUE}message${NORMAL}:
171 Commit message describing changes and listing names/emails of anyone (other
172 than the commiter) who contributed.
177 [[ -z "$1" ]] && usage 1
179 while [[ $# > 0 ]] ; do
182 if [[ -z "$ECHANGELOG_USER" ]] ; then
183 echo "!!! Error: --changelog option requires ECHANGELOG_USER to be set:"
184 echo "!!! export ECHANGELOG_USER=\"Your Name <your@mail.org>\""
214 echo "!!! Error: Unknown option ${1}. See: sunrise-commit -h"
222 if [[ -z "$*" ]] ; then
223 echo "!!! Error: You must supply a commit message. See: sunrise-commit -h"
228 [[ ! -e metadata.xml ]] && cp ../../skel.metadata.xml metadata.xml >/dev/null 2>&1
229 changelog_append "$*" || exit $?
230 create_digests || exit $?
233 if [[ -z "$(svn status)" ]] ; then
234 echo "!!! Error: No changes found in current directory tree. Aborting commit."
238 repoman_check || exit $?
239 svn_commit "$*" || exit $?