summaryrefslogtreecommitdiffstats
path: root/extensions/Splinter/web
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/Splinter/web')
-rw-r--r--extensions/Splinter/web/splinter.js45
1 files changed, 37 insertions, 8 deletions
diff --git a/extensions/Splinter/web/splinter.js b/extensions/Splinter/web/splinter.js
index 87a8b49d5..842bebdb7 100644
--- a/extensions/Splinter/web/splinter.js
+++ b/extensions/Splinter/web/splinter.js
@@ -236,12 +236,23 @@ Splinter.Patch = {
HUNK_START_RE : /^@@[ \t]+-(\d+),(\d+)[ \t]+\+(\d+),(\d+)[ \t]+@@(.*)\n/mg,
HUNK_RE : /((?:[ +\\-].*\n)*)/mg,
+ GIT_FILE_RE : /^diff --git a\/(\S+).*\n(?:(new|deleted) file mode \d+\n)?(?:index.*\n)?GIT binary patch\n(delta )?/mg,
+
_cleanIntro : function(intro) {
var m;
- intro = Splinter.Utils.strip(intro);
+ intro = Splinter.Utils.strip(intro) + "\n\n";
+
+ // Git: remove binary diffs
+ var binary_re = /^(?:diff --git .*\n|literal \d+\n)(?:.+\n)+\n/mg;
+ m = binary_re.exec(intro);
+ while (m) {
+ intro = intro.substr(m.index + m[0].length);
+ binary_re.lastIndex = 0;
+ m = binary_re.exec(intro);
+ }
- // Git: remove leading 'From <commit_id> <date'
+ // 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);
@@ -253,7 +264,7 @@ Splinter.Patch = {
intro = intro.substr(0, m.index);
}
- return intro;
+ return Splinter.Utils.strip(intro);
}
};
@@ -470,10 +481,24 @@ Splinter.Patch.Patch.prototype = {
this.files = [];
var m = Splinter.Patch.FILE_START_RE.exec(text);
- if (m != null) {
- this.intro = Splinter.Patch._cleanIntro(text.substring(0, m.index));
- } else {
+ var bm = Splinter.Patch.GIT_FILE_RE.exec(text);
+ if (m == null && bm == null)
throw "Not a patch";
+ this.intro = m == null ? '' : Splinter.Patch._cleanIntro(text.substring(0, m.index));
+
+ // show binary files in the intro
+
+ if (bm && this.intro.length)
+ this.intro += "\n\n";
+ while (bm != null) {
+ if (bm[2]) {
+ // added or deleted file
+ this.intro += bm[2].charAt(0).toUpperCase() + bm[2].slice(1) + ' Binary File: ' + bm[1] + "\n";
+ } else {
+ // delta
+ this.intro += 'Modified Binary File: ' + bm[1] + "\n";
+ }
+ bm = Splinter.Patch.GIT_FILE_RE.exec(text);
}
while (m != null) {
@@ -1630,6 +1655,7 @@ Splinter.insertCommentEditor = function (commentArea, file, location, type) {
var commentTextArea = new Element(document.createElement('textarea'));
Dom.setAttribute(commentTextArea, 'id', 'commentTextArea');
+ Dom.setAttribute(commentTextArea, 'tabindex', 1);
commentTextArea.appendChild(document.createTextNode(previousText));
commentTextArea.appendTo(commentTextFrame);
Event.addListener('commentTextArea', 'keydown', function (e) {
@@ -1651,6 +1677,7 @@ Splinter.insertCommentEditor = function (commentArea, file, location, type) {
commentCancel.set('id','commentCancel');
commentCancel.set('type', 'button');
commentCancel.set('value', 'Cancel');
+ Dom.setAttribute(commentCancel, 'tabindex', 4);
commentCancel.appendTo(commentEditorLeftButtons);
Event.addListener('commentCancel', 'click', function () { Splinter.cancelComment(previousText); });
@@ -1659,6 +1686,7 @@ Splinter.insertCommentEditor = function (commentArea, file, location, type) {
commentDelete.set('id','commentDelete');
commentDelete.set('type', 'button');
commentDelete.set('value', 'Delete');
+ Dom.setAttribute(commentDelete, 'tabindex', 3);
commentDelete.appendTo(commentEditorLeftButtons);
Event.addListener('commentDelete', 'click', Splinter.deleteComment);
}
@@ -1671,6 +1699,7 @@ Splinter.insertCommentEditor = function (commentArea, file, location, type) {
commentSave.set('id','commentSave');
commentSave.set('type', 'button');
commentSave.set('value', 'Save');
+ Dom.setAttribute(commentSave, 'tabindex', 2);
commentSave.appendTo(commentEditorRightButtons);
Event.addListener('commentSave', 'click', Splinter.saveComment);
@@ -2512,7 +2541,7 @@ Splinter.init = function () {
}
Dom.get("bugId").innerHTML = Splinter.theBug.id;
- Dom.get("bugLink").setAttribute('href', Splinter.configBugzillaUrl + "show_bug.cgi?id=" + Splinter.theBug.id);
+ Dom.get("bugLink").setAttribute('href', Splinter.configBugUrl + "show_bug.cgi?id=" + Splinter.theBug.id);
Dom.get("bugShortDesc").innerHTML = YAHOO.lang.escapeHTML(Splinter.theBug.shortDesc);
Dom.get("bugReporter").appendChild(document.createTextNode(Splinter.theBug.getReporter()));
Dom.get("bugCreationDate").innerHTML = Splinter.Utils.formatDate(Splinter.theBug.creationDate);
@@ -2535,7 +2564,7 @@ Splinter.init = function () {
} else {
Dom.get("attachId").innerHTML = Splinter.theAttachment.id;
- Dom.get("attachLink").setAttribute('href', Splinter.configBugzillaUrl + "attachment.cgi?id=" + Splinter.theAttachment.id);
+ Dom.get("attachLink").setAttribute('href', Splinter.configBugUrl + "attachment.cgi?id=" + Splinter.theAttachment.id);
Dom.get("attachDesc").innerHTML = YAHOO.lang.escapeHTML(Splinter.theAttachment.description);
Dom.get("attachCreator").appendChild(document.createTextNode(Splinter.Bug._formatWho(Splinter.theAttachment.whoName,
Splinter.theAttachment.whoEmail)));