[bugzilla-gnome-org-extensions] Read and display patch "into"
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] Read and display patch "into"
- Date: Thu, 20 Nov 2014 22:17:37 +0000 (UTC)
commit c363af00ca32c58fabfbc66972402c7583239d19
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sat Sep 12 09:54:19 2009 -0400
Read and display patch "into"
Extract the lines in the patch before the first hunks,
strip off whitespace and git'isms like 'diff --stat' output,
and show at the top of the page.
js/patch.js | 22 ++++++++++++++++++++++
js/splinter.js | 5 +++++
tests/patch.jst | 32 ++++++++++++++++++++++++++++++++
web/splinter.css | 8 ++++++++
4 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/js/patch.js b/js/patch.js
index ee81ee7..98afb2d 100644
--- a/js/patch.js
+++ b/js/patch.js
@@ -225,6 +225,24 @@ File.prototype = {
}
};
+function _cleanIntro(intro) {
+ var m;
+
+ intro = Utils.strip(intro);
+
+ // Git: remove leading 'From <commit_id> <date'
+ m = /^From\s+[a-f0-9]{40}.*\n/.exec(intro);
+ if (m)
+ intro = intro.substr(m.index + m[0].length);
+
+ // Git: remove 'diff --stat' output from the end
+ m = /^---\n(?:^\s.*\n)+\s+\d+\s+files changed.*\n?(?!.)/m.exec(intro);
+ if (m)
+ intro = intro.substr(0, m.index);
+
+ return intro;
+}
+
// Matches the start unified diffs for a file as produced by different version control tools
const FILE_START_RE = /^(?:(?:Index|index|===|RCS|diff).*\n)*---[ \t]*(\S+).*\n\+\+\+[
\t]*(\S+).*\n(?=@@)/mg;
@@ -246,6 +264,10 @@ Patch.prototype = {
this.files = [];
var m = FILE_START_RE.exec(text);
+ if (m != null)
+ this.intro = _cleanIntro(text.substring(0, m.index));
+ else
+ throw "Not a patch";
while (m != null) {
// git and hg show a diff between a/foo/bar.c and b/foo/bar.c
diff --git a/js/splinter.js b/js/splinter.js
index 4e49db9..508be32 100644
--- a/js/splinter.js
+++ b/js/splinter.js
@@ -297,6 +297,11 @@ function start(xml) {
$("#bugReporter").text(theBug.getReporter());
$("#bugCreationDate").text(Utils.formatDate(theBug.creationDate));
+ if (thePatch.intro)
+ $("#patchIntro").text(thePatch.intro);
+ else
+ $("#patchIntro").hide();
+
for (i = 0; i < theBug.attachments.length; i++) {
var attachment = theBug.attachments[i];
if (attachment.id == attachmentId) {
diff --git a/tests/patch.jst b/tests/patch.jst
index d2e93ca..a8647ac 100644
--- a/tests/patch.jst
+++ b/tests/patch.jst
@@ -142,3 +142,35 @@ assertEquals(<<<
file = patch.getFile('src/zeitgeist_gui/zeitgeist_panel_widgets.py');
assertEquals(file.getLocation(515, 515), 11);
+patch = new Patch.Patch(<<<
+From f96fb5c7ee6e14725bba8518c1da59ce4e410724 Mon Sep 17 00:00:00 2001
+From: Owen W. Taylor <otaylor fishsoup net>
+Date: Fri, 11 Sep 2009 16:57:19 -0400
+Subject: [PATCH] Fix missing semicolons in flattener.py output
+
+Add semicolons after generated 'a = b' assignments.
+---
+ flattener.py | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/flattener.py b/flattener.py
+index eee73b8..038ae2e 100755
+--- a/flattener.py
++++ b/flattener.py
+@@ -63,4 +63,4 @@ class Flattener(object):
+ module_name = m.group(1)
+ if not module_name in self.flattened_modules:
+ self.flattened_modules.add(module_name)
+- print "var %s = {}" % module_name
++ print "var %s = {};" % module_name
+--
+1.6.2.5
+>>>);
+
+assertEquals(<<<
+From: Owen W. Taylor <otaylor fishsoup net>
+Date: Fri, 11 Sep 2009 16:57:19 -0400
+Subject: [PATCH] Fix missing semicolons in flattener.py output
+
+Add semicolons after generated 'a = b' assignments.
+>>>, patch.intro);
diff --git a/web/splinter.css b/web/splinter.css
index 976dce8..7ac1161 100644
--- a/web/splinter.css
+++ b/web/splinter.css
@@ -36,6 +36,14 @@ body {
padding: 0.5em;
}
+#patchIntro {
+ border: 1px solid #888888;
+ font-size: 90%;
+ margin-bottom: 1em;
+ white-space: pre;
+ padding: 0.5em;
+}
+
.review {
border: 1px solid black;
font-size: 90%;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]