This commit is contained in:
Mario Fetka 2011-11-02 13:32:30 +01:00
parent 8c3de565a3
commit f167579796
4 changed files with 84 additions and 56 deletions

View File

@ -6,10 +6,10 @@ man1_MANS = go-commit.1
go-commit: go-commit:
$(CP) sunrise-commit go-commit $(CP) repo-commit go-commit
go-commit.1: go-commit.1:
$(CP) sunrise-commit.1 go-commit.1 $(CP) repo-commit.1 go-commit.1
go-series2epatch: go-series2epatch:
$(CP) series2epatch go-series2epatch $(CP) series2epatch go-series2epatch

View File

@ -1,5 +1,5 @@
AC_PREREQ([2.59]) AC_PREREQ([2.59])
AC_INIT([go-utils], [0.3]) AC_INIT([go-utils], [0.3.1])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.6 foreign dist-bzip2 no-dependencies]) AM_INIT_AUTOMAKE([1.6 foreign dist-bzip2 no-dependencies])
@ -27,6 +27,6 @@ AC_CONFIG_FILES([distclean-0.3.py], [chmod +x distclean-0.3.py])
AC_CONFIG_FILES([lfspatch], [chmod +x lfspatch]) AC_CONFIG_FILES([lfspatch], [chmod +x lfspatch])
AC_CONFIG_FILES([redigest], [chmod +x redigest]) AC_CONFIG_FILES([redigest], [chmod +x redigest])
AC_CONFIG_FILES([series2epatch], [chmod +x series2epatch]) AC_CONFIG_FILES([series2epatch], [chmod +x series2epatch])
AC_CONFIG_FILES([sunrise-commit.1], [chmod +x sunrise-commit.1]) AC_CONFIG_FILES([repo-commit.1], [chmod +x repo-commit.1])
AC_CONFIG_FILES([sunrise-commit], [chmod +x sunrise-commit]) AC_CONFIG_FILES([repo-commit], [chmod +x repo-commit])
AC_OUTPUT AC_OUTPUT

View File

@ -1,19 +1,19 @@
.TH GO-COMMIT 1 "13 Jul 2010" "@PACKAGE_STRING@" "User Commands" .TH SUNRISE-COMMIT 1 "13 Jul 2010" "@PACKAGE_STRING@" "User Commands"
.SH NAME .SH NAME
go-commit \- a Gentoo repository commit helper. repo-commit \- a Gentoo repository commit helper.
.SH SYNOPSIS .SH SYNOPSIS
.B go-commit .B repo-commit
[options] [options]
[--] [--]
.I <commit-message> .I <commit-message>
.SH DESCRIPTION .SH DESCRIPTION
.B go-commit .B repo-commit
is a helper script for Gentoo repository commiters. Apart from is a helper script for Gentoo repository commiters. Apart from
performing the actual commit, it performs the following tasks: performing the actual commit, it performs the following tasks:
@ -64,6 +64,12 @@ Force proceeding with the commit even if QA violations occur. With
this option, errors from `\fIrepoman full\fP' will be ignored and this option, errors from `\fIrepoman full\fP' will be ignored and
\fB--force\fP is passed to `\fIrepoman commit\fP'. \fB--force\fP is passed to `\fIrepoman commit\fP'.
.IP "\fB-H\fP, \fB--nochangelog\fP"
Disable appending ChangeLog entries and reverting them. In other words,
this option makes sure \fBrepo-commit\fP won't touch the ChangeLog at
all.
.IP "\fB-m\fP, \fB--noformat\fP" .IP "\fB-m\fP, \fB--noformat\fP"
Do not prepend the commit message with package names. Do not prepend the commit message with package names.
@ -94,8 +100,8 @@ Print the version string and exit.
.IP ECHANGELOG_USER .IP ECHANGELOG_USER
the committer name and e-mail as it would appear in ChangeLog. The committer name and e-mail as it would appear in ChangeLog.
The go-suggested format is: The sunrise-suggested format is:
.IR "Real Name" " (" nickname ") <" e-mail > .IR "Real Name" " (" nickname ") <" e-mail >
@ -105,7 +111,7 @@ The go-suggested format is:
.IP "Adding and Updating Packages" .IP "Adding and Updating Packages"
The primary use of \fBgo-commit\fP is to add packages to a Gentoo The primary use of \fBrepo-commit\fP is to add packages to a Gentoo
repository or update existing packages. In order to use it this way, repository or update existing packages. In order to use it this way,
you are expected to run it from within the package's directory, you are expected to run it from within the package's directory,
providing an appropriate changelog message. (The package's directory providing an appropriate changelog message. (The package's directory
@ -113,9 +119,9 @@ is the directory holding its ebuilds).
If your package requires an additional file to be committed outside If your package requires an additional file to be committed outside
the package directory (e.g. an eclass, a license), then you need to the package directory (e.g. an eclass, a license), then you need to
commit that file manually \fBbefore\fP using \fBgo-commit\fP. commit that file manually \fBbefore\fP using \fBrepo-commit\fP.
\fBgo-commit\fP will update the ChangeLog entry and call \fBrepo-commit\fP will update the ChangeLog entry and call
.BR repoman (1) .BR repoman (1)
to do the actual commit for you. If the package's ChangeLog should to do the actual commit for you. If the package's ChangeLog should
\fBnot\fP be updated for a particular commit, use \fB--trivial\fP. \fBnot\fP be updated for a particular commit, use \fB--trivial\fP.
@ -124,17 +130,17 @@ If you are adding a new package and using subversion or a similar VCS,
you may get a warning that your VCS's update command failed. For you may get a warning that your VCS's update command failed. For
example, subversion's update command fails when run from a newly added, example, subversion's update command fails when run from a newly added,
but not yet committed, directory. To avoid this warning, you may use but not yet committed, directory. To avoid this warning, you may use
\fB--noupdate\fP. This option prevents \fBgo-commit\fP from calling the \fB--noupdate\fP. This option prevents \fBrepo-commit\fP from calling the
VCS's update command (which only happens if you are not using DVCS). VCS's update command (which only happens if you are not using DVCS).
.IP "Removing Packages" .IP "Removing Packages"
\fBgo-commit\fP can be used to remove a set of packages too. In order to \fBrepo-commit\fP can be used to remove a set of packages too. In order to
do so, first mark all the expected packages as removed using your VCS. do so, first mark all the expected packages as removed using your VCS.
Next, perform the necessary \fBpackage.mask\fP changes and remove Next, perform the necessary \fBpackage.mask\fP changes and remove
licenses no longer in use. licenses no longer in use.
Afterwards, call \fBgo-commit\fP from within your repository's root Afterwards, call \fBrepo-commit\fP from within your repository's root
directory, passing the removal reason as an argument. The script will directory, passing the removal reason as an argument. The script will
prepend your commit message with the complete removed package list. prepend your commit message with the complete removed package list.
@ -144,7 +150,7 @@ atomic package removal commit, where \fBpackage.mask\fP entries and
files used only by the removed packages are removed. However, this can files used only by the removed packages are removed. However, this can
cause trouble if the working copy is dirty. cause trouble if the working copy is dirty.
\fBgo-commit\fP will check whether any removed package is still \fBrepo-commit\fP will check whether any removed package is still
referenced by any of the other packages by default. If it finds an referenced by any of the other packages by default. If it finds an
internal package reference, it will give an error message. This is in internal package reference, it will give an error message. This is in
order to ensure that no package will be left with unsatisfied order to ensure that no package will be left with unsatisfied
@ -165,7 +171,7 @@ $ svn mkdir app-foo/bar
$ cd app-foo/bar $ cd app-foo/bar
[...] [...]
$ svn add bar-1.ebuild $ svn add bar-1.ebuild
$ go-commit 'New ebuild for bug #nnnnnn.' $ repo-commit 'New ebuild for bug #nnnnnn.'
.fi .fi
.I "2. Performing a version bump:" .I "2. Performing a version bump:"
@ -174,23 +180,23 @@ $ go-commit 'New ebuild for bug #nnnnnn.'
$ cd app-foo/bar $ cd app-foo/bar
$ svn mv bar-1.ebuild bar-2.ebuild $ svn mv bar-1.ebuild bar-2.ebuild
[...] [...]
$ go-commit 'Version bump.' $ repo-commit 'Version bump.'
.fi .fi
.I "3. Fixing a broken Manifest:" .I "3. Fixing a broken Manifest:"
.nf .nf
$ cd app-foo/bar $ cd app-foo/bar
$ go-commit -t 'Fixing a broken Manifest.' $ repo-commit -t 'Fixing a broken Manifest.'
.fi .fi
(\fBgo-commit\fP always updates the Manifest) (\fBrepo-commit\fP always updates the Manifest)
.I "4. Removing a package which was added to gx86:" .I "4. Removing a package which was added to gx86:"
.nf .nf
$ svn rm app-foo/bar $ svn rm app-foo/bar
$ go-commit -f 'in gx86.' $ repo-commit -f 'in gx86.'
.fi .fi
.SH "REPORTING BUGS" .SH "REPORTING BUGS"
@ -201,9 +207,9 @@ Please report bugs via Gentoo Bugzilla:
.SH AUTHORS .SH AUTHORS
Michal Gorny <gentoo@mgorny.alt.pl> Michal Gorny <mgorny@gentoo.org>
Nathan Phillip Brink <ohnobinki@ohnopublishing.net> Nathan Phillip Brink <binki@gentoo.org>
.SH "SEE ALSO" .SH "SEE ALSO"

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# go-commit -- a Gentoo repository commit helper # sunrise-commit -- a Gentoo repository commit helper
# (c) 2010 Michał Górny <gentoo@mgorny.alt.pl> # (c) 2011 Michał Górny & Nathan Phillip Brink
# Released under the terms of the 3-clause BSD license. # Released under the terms of the 2-clause BSD license.
# -- output helpers -- # -- output helpers --
@ -44,7 +44,7 @@ local_supported() {
} }
# If it is not, declare dummy local() function unsetting the variables. # If it is not, declare dummy local() function unsetting the variables.
local_supported || eval 'local() { ( local_supported ) || eval 'local() {
unset "${@}" unset "${@}"
}' }'
@ -52,14 +52,12 @@ local_supported || eval 'local() {
# See if we're in a repo, and what VCS are we using. # See if we're in a repo, and what VCS are we using.
find_repo() { find_repo() {
: ${SC_WANT_CHANGELOG=}
if svn info >/dev/null 2>&1; then if svn info >/dev/null 2>&1; then
SC_VCS=svn SC_VCS=svn
SC_WANT_CHANGELOG=1 : ${SC_WANT_CHANGELOG=1}
elif cvs status -l >/dev/null 2>&1; then elif cvs status -l >/dev/null 2>&1; then
SC_VCS=cvs SC_VCS=cvs
SC_WANT_CHANGELOG=1 : ${SC_WANT_CHANGELOG=1}
elif hg tip >/dev/null 2>&1; then elif hg tip >/dev/null 2>&1; then
SC_VCS=hg SC_VCS=hg
else else
@ -69,7 +67,7 @@ find_repo() {
if [ ${ret} -ne 127 ] && [ ${ret} -ne 128 ]; then if [ ${ret} -ne 127 ] && [ ${ret} -ne 128 ]; then
if echo "${remotes}" | grep git-svn >/dev/null 2>&1; then if echo "${remotes}" | grep git-svn >/dev/null 2>&1; then
SC_WANT_CHANGELOG=1 : ${SC_WANT_CHANGELOG=1}
fi fi
SC_VCS=git SC_VCS=git
else else
@ -279,16 +277,17 @@ vcs_update() {
print_help() { print_help() {
cat <<_EOH_ cat <<_EOH_
Synopsis: Synopsis:
go-commit [options] [--] <commit message> sunrise-commit [options] [--] <commit message>
Options: Options:
-?, -h, --help print this message, -?, -h, --help print this message,
-V, --version print version string, -V, --version print version string,
-c, --changelog backwards compat (ignored), -c, --changelog force creating a ChangeLog entry,
-C, --nocolor disable colorful output, -C, --nocolor disable colorful output,
-d, --noupdate disable updating the repository, -d, --noupdate disable updating the repository,
-f, --force force repoman to proceed with the commit, -f, --force force repoman to proceed with the commit,
-H, --nochangelog do not append to ChangeLog nor revert it,
-m, --noformat do not prepend the commit message with package names, -m, --noformat do not prepend the commit message with package names,
-q, --quiet backwards compat (ignored), -q, --quiet backwards compat (ignored),
-t, --trivial trivial changes (do not add a ChangeLog entry), -t, --trivial trivial changes (do not add a ChangeLog entry),
@ -320,7 +319,7 @@ confirm() {
# Guess what! # Guess what!
main() { main() {
local commitmsg force monochrome noprepend noupdate trivial local commitmsg force monochrome noprepend noupdate trivial
unset SC_VERBOSE unset SC_VERBOSE SC_WANT_CHANGELOG
# Command-line parsing. # Command-line parsing.
while [ ${#} -gt 0 ]; do while [ ${#} -gt 0 ]; do
@ -335,7 +334,7 @@ main() {
;; ;;
-c|--changelog) -c|--changelog)
SC_WANT_CHANGELOG=1 SC_WANT_CHANGELOG=force
;; ;;
-C|--nocolor) -C|--nocolor)
monochrome=1 monochrome=1
@ -346,6 +345,9 @@ main() {
-f|--force) -f|--force)
force=1 force=1
;; ;;
-H|--nochangelog)
SC_WANT_CHANGELOG=
;;
-m|--noformat) -m|--noformat)
noprepend= noprepend=
;; ;;
@ -409,22 +411,40 @@ main() {
vcs_update vcs_update
fi fi
local bns bn word bug_next
for word in ${commitmsg}; do
case ${word} in
[Bb][Uu][Gg])
bug_next=1
;;
\#*)
bn="${word}"
;;
*)
[ -z "${bug_next}" ] && continue
bn="${word}"
bug_next=
;;
esac
if [ -n "${bn}" ]; then
bns="${bns:+${bns} }$(expr "${bn}" : '[^[:digit:]]*\([[:digit:]]\{1,\}\)')"
bn=
fi
done
# With DVCS repos, we do not do ChangeLogs by default... # With DVCS repos, we do not do ChangeLogs by default...
# ...at least unless they're already there. # ...at least unless they're already there.
if [ -n "${SC_WANT_CHANGELOG}" ] || [ -f ChangeLog ]; then [ -f ChangeLog ] && : ${SC_WANT_CHANGELOG=1}
if [ -n "${SC_WANT_CHANGELOG}" ]; then
sayv 'Cleaning up the ChangeLog...' sayv 'Cleaning up the ChangeLog...'
vcs_reset ChangeLog vcs_reset ChangeLog
local bns
# Let's take a lucky guess bugnumbers consist of 4+ digits.
bns=$(echo "${commitmsg}" | grep -o -E '[0-9]{4,}')
# Creating a new ChangeLog? Let's take a look at the commit message. # Creating a new ChangeLog? Let's take a look at the commit message.
if [ ! -f ChangeLog ]; then if [ ! -f ChangeLog ]; then
[ -n "${trivial}" ] && die "Trivial change for an initial commit? You're joking, right?" [ -n "${trivial}" ] && die "Trivial change for an initial commit? You're joking, right?"
# Geos_One-specific checks. # Sunrise-specific checks.
if [ "$(cat ../../profiles/repo_name 2>/dev/null)" = "go" ]; then if [ "$(cat ../../profiles/repo_name 2>/dev/null)" = "sunrise" ]; then
[ -z "${bns}" ] && die 'Please supply the bug number in the initial commit message!' [ -z "${bns}" ] && die 'Please supply the bug number in the initial commit message!'
if [ ! -f metadata.xml ]; then if [ ! -f metadata.xml ]; then
req cp ../../skel.metadata.xml metadata.xml req cp ../../skel.metadata.xml metadata.xml
@ -436,22 +456,24 @@ main() {
fi fi
if [ -z "${trivial}" ]; then if [ -z "${trivial}" ]; then
local ecopts
[ ${SC_WANT_CHANGELOG} = force ] && ecopts=--no-strict
sayv '...and appending to it.' sayv '...and appending to it.'
echangelog --vcs ${SC_VCS} "${commitmsg}" \ echangelog --vcs ${SC_VCS} ${ecopts} "${commitmsg}" \
|| die 'Please correct the problems shown by echangelog.' || die 'Please correct the problems shown by echangelog.'
echo echo
fi fi
fi
if [ -n "${bns}" ]; then if [ -n "${bns}" ]; then
local bn cbn local bn cbn
for bn in ${bns}; do for bn in ${bns}; do
cbn=#${WHITE}${bn}${NORMAL} cbn=#${WHITE}${bn}${NORMAL}
wget -q http://bugs.gentoo.org/show_bug.cgi?id=${bn} -O - | sed -n \ wget -q http://bugs.gentoo.org/show_bug.cgi?id=${bn} -O - | sed -n \
-e "s, *<title>Gentoo Bug \([0-9]*\) - \(.*\)</title>,Bug ${cbn}: ${BGREEN}\2${RESET},p" \ -e "s, *<title>\(Gentoo \)\?Bug \([0-9]*\) \(-\|&ndash;\) \(.*\)</title>,Bug ${cbn}: ${BGREEN}\4${RESET},p" \
-e "s, *<title>Gentoo \(Invalid Bug ID\)</title>,Bug ${cbn}: ${YELLOW}!! \1${RESET},p" -e "s, *<title>\(Gentoo \)\?\(Invalid Bug ID\)</title>,Bug ${cbn}: ${YELLOW}!! \2${RESET},p"
done done
echo echo
fi
fi fi
if [ ${SC_VCS} != cvs ] || [ -n "${noupdate}" ]; then if [ ${SC_VCS} != cvs ] || [ -n "${noupdate}" ]; then