Make the ciabot scripts completely self-configuring in the normal case.
Signed-off-by: Eric S. Raymond <esr@thyrsus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
6484070168
commit
df1effa690
|
@ -8,22 +8,38 @@ It is no longer necessary to modify the script in order to put it
|
||||||
in place; in fact, this is now discouraged. It is entirely
|
in place; in fact, this is now discouraged. It is entirely
|
||||||
configurable with the following git config variables:
|
configurable with the following git config variables:
|
||||||
|
|
||||||
ciabot.project = name of the project (required)
|
ciabot.project = name of the project
|
||||||
ciabot.repo = name of the project repo for gitweb/cgit purposes
|
ciabot.repo = name of the project repo for gitweb/cgit purposes
|
||||||
ciabot.xmlrpc = if true (default), ship notifications via XML-RPC
|
ciabot.xmlrpc = if true, ship notifications via XML-RPC
|
||||||
ciabot.revformat = format in which the revision is shown
|
ciabot.revformat = format in which the revision is shown
|
||||||
|
|
||||||
The ciabot.repo value defaults to ciabot.project lowercased.
|
|
||||||
|
|
||||||
The revformat variable may have the following values
|
The revformat variable may have the following values
|
||||||
raw -> full hex ID of commit
|
raw -> full hex ID of commit
|
||||||
short -> first 12 chars of hex ID
|
short -> first 12 chars of hex ID
|
||||||
describe -> describe relative to last tag, falling back to short
|
describe -> describe relative to last tag, falling back to short
|
||||||
The default is 'describe'.
|
|
||||||
|
ciabot.project defaults to the directory name of the repository toplevel.
|
||||||
|
ciabot.repo defaults to ciabot.project lowercased.
|
||||||
|
ciabot.xmlrpc defaults to True
|
||||||
|
ciabot.revformat defaults to 'describe'.
|
||||||
|
|
||||||
|
This means that in the normal case you need not do any configuration at all,
|
||||||
|
however setting ciabot.project will allow the hook to run slightly faster.
|
||||||
|
|
||||||
Once you've set these variables, try your script with -n to see the
|
Once you've set these variables, try your script with -n to see the
|
||||||
notification message dumped to stdout and verify that it looks sane.
|
notification message dumped to stdout and verify that it looks sane.
|
||||||
|
|
||||||
|
To live-test these scripts, your project needs to have been registered with
|
||||||
|
the CIA site. Here are the steps:
|
||||||
|
|
||||||
|
1. Open an IRC window on irc://freenode/commits or your registered
|
||||||
|
project IRC channel.
|
||||||
|
|
||||||
|
2. Run ciabot.py and/or ciabot.sh from any directory under git
|
||||||
|
control.
|
||||||
|
|
||||||
|
You should see a notification on the channel for your most recent commit.
|
||||||
|
|
||||||
After verifying correct function, install one of these scripts either
|
After verifying correct function, install one of these scripts either
|
||||||
in a post-commit hook or in an update hook.
|
in a post-commit hook or in an update hook.
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,4 @@ You probably want the Python version; it's faster, more capable, and
|
||||||
better documented. The shell version is maintained only as a fallback
|
better documented. The shell version is maintained only as a fallback
|
||||||
for use on hosting sites that don't permit Python hook scripts.
|
for use on hosting sites that don't permit Python hook scripts.
|
||||||
|
|
||||||
To test these scripts, your project needs to have been registered with
|
|
||||||
the CIA site. Here are the steps:
|
|
||||||
|
|
||||||
1. Open an IRC window on irc://freenode/commits or your registered
|
|
||||||
project IRC channel.
|
|
||||||
|
|
||||||
2. Run ciabot.py and/or ciabot.sh from any directory under git
|
|
||||||
control, using the -p option to pass in your project name.
|
|
||||||
|
|
||||||
You should see a notification on the channel for your most recent commit.
|
|
||||||
|
|
||||||
See the file INSTALL for installation instructions.
|
See the file INSTALL for installation instructions.
|
||||||
|
|
|
@ -10,11 +10,9 @@
|
||||||
# usage: ciabot.py [-V] [-n] [-p projectname] [refname [commits...]]
|
# usage: ciabot.py [-V] [-n] [-p projectname] [refname [commits...]]
|
||||||
#
|
#
|
||||||
# This script is meant to be run either in a post-commit hook or in an
|
# This script is meant to be run either in a post-commit hook or in an
|
||||||
# update hook. If there's nothing unusual about your hosting setup,
|
# update hook. Try it with -n to see the notification mail dumped to
|
||||||
# you can specify the project name and repo with config variables and
|
# stdout and verify that it looks sane. With -V it dumps its version
|
||||||
# avoid having to modify this script. Try it with -n to see the
|
# and exits.
|
||||||
# notification mail dumped to stdout and verify that it looks
|
|
||||||
# sane. With -V it dumps its version and exits.
|
|
||||||
#
|
#
|
||||||
# In post-commit, run it without arguments. It will query for
|
# In post-commit, run it without arguments. It will query for
|
||||||
# current HEAD and the latest commit ID to get the information it
|
# current HEAD and the latest commit ID to get the information it
|
||||||
|
@ -27,12 +25,17 @@
|
||||||
# /path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac)
|
# /path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac)
|
||||||
#
|
#
|
||||||
# Configuration variables affecting this script:
|
# Configuration variables affecting this script:
|
||||||
# ciabot.project = name of the project (required)
|
#
|
||||||
|
# ciabot.project = name of the project
|
||||||
# ciabot.repo = name of the project repo for gitweb/cgit purposes
|
# ciabot.repo = name of the project repo for gitweb/cgit purposes
|
||||||
# ciabot.xmlrpc = if true (default), ship notifications via XML-RPC
|
# ciabot.xmlrpc = if true (default), ship notifications via XML-RPC
|
||||||
# ciabot.revformat = format in which the revision is shown
|
# ciabot.revformat = format in which the revision is shown
|
||||||
#
|
#
|
||||||
# The ciabot.repo value defaults to ciabot.project lowercased.
|
# ciabot.project defaults to the directory name of the repository toplevel.
|
||||||
|
# ciabot.repo defaults to ciabot.project lowercased.
|
||||||
|
#
|
||||||
|
# This means that in the normal case you need not do any configuration at all,
|
||||||
|
# but setting the project name will speed it up slightly.
|
||||||
#
|
#
|
||||||
# The revformat variable may have the following values
|
# The revformat variable may have the following values
|
||||||
# raw -> full hex ID of commit
|
# raw -> full hex ID of commit
|
||||||
|
@ -102,7 +105,7 @@ toaddr = "cia@cia.vc"
|
||||||
# Identify the generator script.
|
# Identify the generator script.
|
||||||
# Should only change when the script itself gets a new home and maintainer.
|
# Should only change when the script itself gets a new home and maintainer.
|
||||||
generator = "http://www.catb.org/~esr/ciabot.py"
|
generator = "http://www.catb.org/~esr/ciabot.py"
|
||||||
version = "3.5"
|
version = "3.6"
|
||||||
|
|
||||||
def do(command):
|
def do(command):
|
||||||
return commands.getstatusoutput(command)[1]
|
return commands.getstatusoutput(command)[1]
|
||||||
|
@ -192,10 +195,17 @@ if __name__ == "__main__":
|
||||||
print "ciabot.py: version", version
|
print "ciabot.py: version", version
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Cough and die if user has not specified a project
|
# The project variable defaults to the name of the repository toplevel.
|
||||||
if not project:
|
if not project:
|
||||||
sys.stderr.write("ciabot.py: no project specified, bailing out.\n")
|
here = os.getcwd()
|
||||||
sys.exit(1)
|
while True:
|
||||||
|
if os.path.exists(os.path.join(here, ".git")):
|
||||||
|
project = os.path.basename(here)
|
||||||
|
break
|
||||||
|
elif here == '/':
|
||||||
|
sys.stderr.write("ciabot.py: no .git below root!\n")
|
||||||
|
sys.exit(1)
|
||||||
|
here = os.path.dirname(here)
|
||||||
|
|
||||||
if not repo:
|
if not repo:
|
||||||
repo = project.lower()
|
repo = project.lower()
|
||||||
|
|
|
@ -21,11 +21,9 @@
|
||||||
# usage: ciabot.sh [-V] [-n] [-p projectname] [refname commit]
|
# usage: ciabot.sh [-V] [-n] [-p projectname] [refname commit]
|
||||||
#
|
#
|
||||||
# This script is meant to be run either in a post-commit hook or in an
|
# This script is meant to be run either in a post-commit hook or in an
|
||||||
# update hook. If there's nothing unusual about your hosting setup,
|
# update hook. Try it with -n to see the notification mail dumped to
|
||||||
# you can specify the project name and repo with config variables and
|
# stdout and verify that it looks sane. With -V it dumps its version
|
||||||
# avoid having to modify this script. Try it with -n to see the
|
# and exits.
|
||||||
# notification mail dumped to stdout and verify that it looks
|
|
||||||
# sane. With -V it dumps its version and exits.
|
|
||||||
#
|
#
|
||||||
# In post-commit, run it without arguments. It will query for
|
# In post-commit, run it without arguments. It will query for
|
||||||
# current HEAD and the latest commit ID to get the information it
|
# current HEAD and the latest commit ID to get the information it
|
||||||
|
@ -44,11 +42,16 @@
|
||||||
# most recent to least - better to ship notifactions from oldest to newest.
|
# most recent to least - better to ship notifactions from oldest to newest.
|
||||||
#
|
#
|
||||||
# Configuration variables affecting this script:
|
# Configuration variables affecting this script:
|
||||||
# ciabot.project = name of the project (makes -p option unnecessary)
|
#
|
||||||
|
# ciabot.project = name of the project
|
||||||
# ciabot.repo = name of the project repo for gitweb/cgit purposes
|
# ciabot.repo = name of the project repo for gitweb/cgit purposes
|
||||||
# ciabot.revformat = format in which the revision is shown
|
# ciabot.revformat = format in which the revision is shown
|
||||||
#
|
#
|
||||||
# The ciabot.repo defaults to ciabot.project lowercased.
|
# ciabot.project defaults to the directory name of the repository toplevel.
|
||||||
|
# ciabot.repo defaults to ciabot.project lowercased.
|
||||||
|
#
|
||||||
|
# This means that in the normal case you need not do any configuration at all,
|
||||||
|
# but setting the project name will speed it up slightly.
|
||||||
#
|
#
|
||||||
# The revformat variable may have the following values
|
# The revformat variable may have the following values
|
||||||
# raw -> full hex ID of commit
|
# raw -> full hex ID of commit
|
||||||
|
@ -64,10 +67,27 @@
|
||||||
# shpped from an update in their actual order.)
|
# shpped from an update in their actual order.)
|
||||||
#
|
#
|
||||||
|
|
||||||
# The project as known to CIA. You can also hardwire this or set it with a
|
# The project as known to CIA. You can set this with a -p option,
|
||||||
# -p option.
|
# or let it default to the directory name of the repo toplevel.
|
||||||
project=$(git config --get ciabot.project)
|
project=$(git config --get ciabot.project)
|
||||||
|
|
||||||
|
if [ -z $project ]
|
||||||
|
then
|
||||||
|
here=`pwd`;
|
||||||
|
while :; do
|
||||||
|
if [ -d $here/.git ]
|
||||||
|
then
|
||||||
|
project=`basename $here`
|
||||||
|
break
|
||||||
|
elif [ $here = '/' ]
|
||||||
|
then
|
||||||
|
echo "ciabot.sh: no .git below root!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
here=`dirname $here`
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Name of the repo for gitweb/cgit purposes
|
# Name of the repo for gitweb/cgit purposes
|
||||||
repo=$(git config --get ciabot.repo)
|
repo=$(git config --get ciabot.repo)
|
||||||
[ -z $repo] && repo=$(echo "${project}" | tr '[A-Z]' '[a-z]')
|
[ -z $repo] && repo=$(echo "${project}" | tr '[A-Z]' '[a-z]')
|
||||||
|
@ -100,7 +120,7 @@ urlprefix="http://${host}/cgi-bin/cgit.cgi/${repo}/commit/?id="
|
||||||
# Identify the script. The 'generator' variable should change only
|
# Identify the script. The 'generator' variable should change only
|
||||||
# when the script itself gets a new home and maintainer.
|
# when the script itself gets a new home and maintainer.
|
||||||
generator="http://www.catb.org/~esr/ciabot/ciabot.sh"
|
generator="http://www.catb.org/~esr/ciabot/ciabot.sh"
|
||||||
version=3.4
|
version=3.5
|
||||||
|
|
||||||
# Addresses for the e-mail
|
# Addresses for the e-mail
|
||||||
from="CIABOT-NOREPLY@${hostname}"
|
from="CIABOT-NOREPLY@${hostname}"
|
||||||
|
|
Loading…
Reference in New Issue