diff options
author | Alberto Bertogli <albertito@blitiri.com.ar> | 2015-11-07 12:43:01 +0100 |
---|---|---|
committer | Alberto Bertogli <albertito@blitiri.com.ar> | 2015-11-07 13:04:09 +0100 |
commit | c4e6484bb00e93b55e1f94f3464a40a3bd12f01f (patch) | |
tree | b2be28f4dd45aaca9cdc00b497830664e53646b4 | |
parent | 88dd6fab76231a7cefbb0959a960099352d93c16 (diff) | |
download | git-arr-fork-c4e6484bb00e93b55e1f94f3464a40a3bd12f01f.zip |
git-arr: Always generate the top level index
The top level index contains a "last updated" field, but it doesn't get
updated if using the --only option, which is very common in post-update hooks,
and causes the date to be stale.
This patch fixes that by always generating the top level index, even if --only
was given.
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
-rwxr-xr-x | git-arr | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -284,7 +284,7 @@ def is_404(e): else: return e.status_code == 404 -def generate(output, skip_index = False): +def generate(output, only = None): """Generate static html to the output directory.""" def write_to(path, func_or_str, args = (), mtime = None): path = output + '/' + path @@ -361,8 +361,8 @@ def generate(output, skip_index = False): (str(r.name), str(bn), oname.raw), tree, (r, bn, oname.url), mtime) - if not skip_index: - write_to('index.html', index()) + # Always generate the index, to keep the "last updated" time fresh. + write_to('index.html', index()) # We can't call static() because it relies on HTTP headers. read_f = lambda f: open(f).read() @@ -373,7 +373,11 @@ def generate(output, skip_index = False): write_to('static/syntax.css', read_f, [static_path + '/syntax.css'], os.stat(static_path + '/syntax.css').st_mtime) - for r in sorted(repos.values(), key = lambda r: r.name): + rs = sorted(repos.values(), key = lambda r: r.name) + if only: + rs = [r for r in rs if r.name in only] + + for r in rs: write_to('r/%s/index.html' % r.name, summary(r)) for bn in r.branch_names(): commit_count = 0 @@ -441,18 +445,12 @@ def main(): if not args: parser.error('Must specify an action (serve|generate)') - if 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, - skip_index = len(opts.only) > 0) + generate(output = opts.output, only = opts.only) else: parser.error('Unknown action %s' % args[0]) |