aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Bertogli <albertito@blitiri.com.ar>2018-10-01 22:25:11 +0200
committerAlberto Bertogli <albertito@blitiri.com.ar>2018-10-01 22:39:57 +0200
commitcbb36e087c1bcf1c81de53e920baf0c681abfd87 (patch)
tree6fccb33508c20c66dca0f56ba0b7c97a1cfc1af3
parent722d765973ab368a313455d2179d7b3d67ec25cb (diff)
downloadgit-arr-fork-cbb36e087c1bcf1c81de53e920baf0c681abfd87.zip
Implement a "patch" view0.15
This commit implements a "patch" view, with a simple plain-text representation of a commit, that can be used as a patch file.
-rwxr-xr-xgit-arr17
-rw-r--r--views/patch.tpl8
2 files changed, 25 insertions, 0 deletions
diff --git a/git-arr b/git-arr
index ca0ccfa..5c4e7db 100755
--- a/git-arr
+++ b/git-arr
@@ -61,6 +61,7 @@ def load_config(path):
'embed_markdown': 'yes',
'embed_images': 'no',
'ignore': '',
+ 'generate_patch': 'yes',
}
config = configparser.SafeConfigParser(defaults)
@@ -120,6 +121,7 @@ def load_config(path):
r.info.max_pages = sys.maxint
r.info.generate_tree = config.getboolean(s, 'tree')
r.info.root_diff = config.getboolean(s, 'rootdiff')
+ r.info.generate_patch = config.getboolean(s, 'generate_patch')
r.info.web_url = config.get(s, 'web_url')
web_url_file = fullpath + '/' + config.get(s, 'web_url_file')
@@ -236,6 +238,19 @@ def commit(repo, cid):
return dict(repo = repo, c=c)
+@bottle.route('/r/<repo:repo>/c/<cid:re:[0-9a-f]{5,40}>.patch')
+@bottle.view('patch',
+ # Output is text/plain, don't do HTML escaping.
+ template_settings={"noescape": True})
+def patch(repo, cid):
+ c = repo.commit(cid)
+ if not c:
+ bottle.abort(404, 'Commit not found')
+
+ bottle.response.content_type = 'text/plain; charset=utf8'
+
+ return dict(repo = repo, c=c)
+
@bottle.route('/r/<repo:repo>/b/<bname:path>/t/f=<fname:path>.html')
@bottle.route('/r/<repo:repo>/b/<bname:path>/t/<dirname:path>/f=<fname:path>.html')
@bottle.view('blob')
@@ -396,6 +411,8 @@ def generate(output, only = None):
for cid in commit_ids:
write_to('r/%s/c/%s/index.html' % (r.name, cid),
commit, (r, cid))
+ if r.info.generate_patch:
+ write_to('r/%s/c/%s.patch' % (r.name, cid), patch, (r, cid))
commit_count += 1
# To avoid regenerating files that have not changed, we will
diff --git a/views/patch.tpl b/views/patch.tpl
new file mode 100644
index 0000000..ab3fca1
--- /dev/null
+++ b/views/patch.tpl
@@ -0,0 +1,8 @@
+From: {{c.author_name}} <{{c.author_email}}>
+Date: {{c.author_date}}
+Subject: {{c.subject}}
+
+{{c.body.strip()}}
+---
+
+{{c.diff.body}}