diff options
author | Alberto Bertogli <albertito@blitiri.com.ar> | 2012-11-27 00:55:40 +0100 |
---|---|---|
committer | Alberto Bertogli <albertito@blitiri.com.ar> | 2013-03-10 00:23:52 +0100 |
commit | c303c30755b917c1377b831f2d37abf7841824c8 (patch) | |
tree | 4d975fe647b37e8afb90426bebfab0a8e4201ff2 | |
parent | 9ec2bde5c45c64f7fac432dbd3f23a1883d2b594 (diff) | |
download | git-arr-fork-c303c30755b917c1377b831f2d37abf7841824c8.zip |
Fix the "--only" option
This patch fixes the --only option, and makes it avoid generating the
top-level index so we don't get a broken one with only the specified
repositories.
The intention is that this option is used in hooks to update the views after a
commit or push.
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
-rwxr-xr-x | git-arr | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -247,7 +247,7 @@ def static(path): # Static HTML generation # -def generate(output): +def generate(output, skip_index = False): """Generate static html to the output directory.""" def write_to(path, func_or_str, args = (), mtime = None): path = output + '/' + path @@ -323,7 +323,8 @@ def generate(output): (str(r.name), str(bn), oname.raw), tree, (r, bn, oname.url), mtime) - write_to('index.html', index()) + if not skip_index: + write_to('index.html', index()) # We can't call static() because it relies on HTTP headers. read_f = lambda f: open(f).read() @@ -384,6 +385,7 @@ def main(): parser.add_option('-o', '--output', metavar = 'DIR', help = 'output directory (for generate)') parser.add_option('', '--only', metavar = 'REPO', action = 'append', + default = [], help = 'generate/serve only this repository') opts, args = parser.parse_args() @@ -400,15 +402,17 @@ def main(): parser.error('Must specify an action (serve|generate)') if opts.only: - global repos - repos = [ r for r in repos if r.name in opts.only ] + for rname in list(repos.keys()): + if rname not in opts.only: + del repos[rname] if args[0] == 'serve': bottle.run(host = 'localhost', port = 8008, reloader = True) elif args[0] == 'generate': if not opts.output: parser.error('Must specify --output') - generate(output = opts.output) + generate(output = opts.output, + skip_index = len(opts.only) > 0) else: parser.error('Unknown action %s' % args[0]) |