|
10 | 10 | # usage: ciabot.py [-V] [-n] [-p projectname] [refname [commits...]] |
11 | 11 | # |
12 | 12 | # This script is meant to be run either in a post-commit hook or in an |
13 | | -# update hook. If there's nothing unusual about your hosting setup, |
14 | | -# you can specify the project name and repo with config variables and |
15 | | -# avoid having to modify this script. Try it with -n to see the |
16 | | -# notification mail dumped to stdout and verify that it looks |
17 | | -# sane. With -V it dumps its version and exits. |
| 13 | +# update hook. Try it with -n to see the notification mail dumped to |
| 14 | +# stdout and verify that it looks sane. With -V it dumps its version |
| 15 | +# and exits. |
18 | 16 | # |
19 | 17 | # In post-commit, run it without arguments. It will query for |
20 | 18 | # current HEAD and the latest commit ID to get the information it |
|
27 | 25 | # /path/to/ciabot.py ${refname} $(git rev-list ${oldhead}..${newhead} | tac) |
28 | 26 | # |
29 | 27 | # Configuration variables affecting this script: |
30 | | -# ciabot.project = name of the project (required) |
| 28 | +# |
| 29 | +# ciabot.project = name of the project |
31 | 30 | # ciabot.repo = name of the project repo for gitweb/cgit purposes |
32 | 31 | # ciabot.xmlrpc = if true (default), ship notifications via XML-RPC |
33 | 32 | # ciabot.revformat = format in which the revision is shown |
34 | 33 | # |
35 | | -# The ciabot.repo value defaults to ciabot.project lowercased. |
| 34 | +# ciabot.project defaults to the directory name of the repository toplevel. |
| 35 | +# ciabot.repo defaults to ciabot.project lowercased. |
| 36 | +# |
| 37 | +# This means that in the normal case you need not do any configuration at all, |
| 38 | +# but setting the project name will speed it up slightly. |
36 | 39 | # |
37 | 40 | # The revformat variable may have the following values |
38 | 41 | # raw -> full hex ID of commit |
|
102 | 105 | # Identify the generator script. |
103 | 106 | # Should only change when the script itself gets a new home and maintainer. |
104 | 107 | generator = "http://www.catb.org/~esr/ciabot.py" |
105 | | -version = "3.5" |
| 108 | +version = "3.6" |
106 | 109 |
|
107 | 110 | def do(command): |
108 | 111 | return commands.getstatusoutput(command)[1] |
@@ -192,10 +195,17 @@ def report(refname, merged, xmlrpc=True): |
192 | 195 | print "ciabot.py: version", version |
193 | 196 | sys.exit(0) |
194 | 197 |
|
195 | | - # Cough and die if user has not specified a project |
| 198 | + # The project variable defaults to the name of the repository toplevel. |
196 | 199 | if not project: |
197 | | - sys.stderr.write("ciabot.py: no project specified, bailing out.\n") |
198 | | - sys.exit(1) |
| 200 | + here = os.getcwd() |
| 201 | + while True: |
| 202 | + if os.path.exists(os.path.join(here, ".git")): |
| 203 | + project = os.path.basename(here) |
| 204 | + break |
| 205 | + elif here == '/': |
| 206 | + sys.stderr.write("ciabot.py: no .git below root!\n") |
| 207 | + sys.exit(1) |
| 208 | + here = os.path.dirname(here) |
199 | 209 |
|
200 | 210 | if not repo: |
201 | 211 | repo = project.lower() |
|
0 commit comments