diff options
Diffstat (limited to 'extensions/Splinter')
-rw-r--r-- | extensions/Splinter/lib/Util.pm | 22 | ||||
-rw-r--r-- | extensions/Splinter/template/en/default/pages/splinter.html.tmpl | 10 | ||||
-rw-r--r-- | extensions/Splinter/template/en/default/pages/splinter/help.html.tmpl | 54 | ||||
-rw-r--r-- | extensions/Splinter/web/splinter.js | 45 |
4 files changed, 81 insertions, 50 deletions
diff --git a/extensions/Splinter/lib/Util.pm b/extensions/Splinter/lib/Util.pm index 1861d7ab6..c8c0d52d2 100644 --- a/extensions/Splinter/lib/Util.pm +++ b/extensions/Splinter/lib/Util.pm @@ -21,6 +21,8 @@ package Bugzilla::Extension::Splinter::Util; +use strict; + use Bugzilla; use Bugzilla::Util; @@ -66,9 +68,9 @@ sub get_review_url { my $bug_id = $bug->id; if (defined $absolute && $absolute) { - my $urlbase = correct_urlbase(); - $urlbase =~ s!/$!! if $base =~ "^/"; - $base = $urlbase . $base; + my $urlbase = correct_urlbase(); + $urlbase =~ s!/$!! if $base =~ "^/"; + $base = $urlbase . $base; } if ($base =~ /\?/) { @@ -93,12 +95,12 @@ sub munge_create_attachment { my ($bug, $intro_text, $attach_id, $view_link) = @_; if (attachment_id_is_patch ($attach_id)) { - return ("$intro_text" . + return ("$intro_text" . " View: $view_link\015\012" . " Review: " . get_review_url($bug, $attach_id, 1) . "\015\012"); } else { - return ("$intro_text --> ($view_link)"); + return ("$intro_text --> ($view_link)"); } } @@ -115,24 +117,24 @@ sub add_review_links_to_email { if ($email->header('Subject') =~ /^\[Bug\s+(\d+)\]/ && Bugzilla->user->can_see_bug($1)) { - $bug = Bugzilla::Bug->new($1); + $bug = Bugzilla::Bug->new($1); } return unless defined $bug; if ($body =~ /Review\s+of\s+attachment\s+\d+\s*:/) { - $body =~ s~(Review\s+of\s+attachment\s+(\d+)\s*:) + $body =~ s~(Review\s+of\s+attachment\s+(\d+)\s*:) ~"$1\015\012 --> (" . get_review_url($bug, $2, 1) . ")" ~egx; - $new_body = 1; + $new_body = 1; } if ($body =~ /Created attachment \d+\015\012 --> /) { - $body =~ s~(Created\ attachment\ (\d+)\015\012) + $body =~ s~(Created\ attachment\ (\d+)\015\012) \ -->\ \(([^\015\012]*)\)[^\015\012]* ~munge_create_attachment($bug, $1, $2, $3) ~egx; - $new_body = 1; + $new_body = 1; } $email->body_set($body) if $new_body; diff --git a/extensions/Splinter/template/en/default/pages/splinter.html.tmpl b/extensions/Splinter/template/en/default/pages/splinter.html.tmpl index 4728967c7..0d2648e58 100644 --- a/extensions/Splinter/template/en/default/pages/splinter.html.tmpl +++ b/extensions/Splinter/template/en/default/pages/splinter.html.tmpl @@ -38,7 +38,7 @@ <script type="text/javascript"> Splinter.configBase = '[% urlbase FILTER none %][% Param('splinter_base') FILTER js %]'; - Splinter.configBugzillaUrl = '[% urlbase FILTER none %]'; + Splinter.configBugUrl = '[% urlbase FILTER none %]'; Splinter.configHaveExtension = true; Splinter.configHelp = '[% urlbase FILTER none %]page.cgi?id=splinter/help.html'; Splinter.configNote = ''; @@ -115,7 +115,7 @@ </div> <div id="bugInfo" style="display: none;"> - <b>Bug <a id="bugLink"><span id="bugId"></span></a>:</b> + <b>[% terms.Bug %]<a id="bugLink"><span id="bugId"></span></a>:</b> <span id="bugShortDesc"></span> - <span id="bugReporter"></span> - <span id="bugCreationDate"></span> @@ -138,7 +138,7 @@ <div id="error" style="display: none;"> </div> <div id="enterBug" style="display: none;"> - Bug to review: + [% terms.Bug %] to review: <input id="enterBugInput" /> <input id="enterBugGo" type="button" value="Go" /> <div id="chooseReview" style="display: none;"> @@ -167,7 +167,7 @@ <li>To comment on a specific lines in the patch, first select the filename from the file navigation links.</li> <li>Then double click the line you want to review and a comment box will appear below the line.</li> <li>When the review is complete and you publish it, the overview comment and all line specific comments with their context, - will be combined together into a single review comment on the bug report.</li> + will be combined together into a single review comment on the [% terms.bug %] report.</li> <li>For more detailed instructions, read the Splinter <a id='helpLink' target='splinterHelp' href="[% urlbase FILTER none %]page.cgi?id=splinter/help.html">help page</a>. </li> @@ -233,7 +233,7 @@ </form> <div id="buttonBox"> <span id="attachmentStatusSpan">Patch Status: - <select id="attachmentStatus"> </select> + <select id="attachmentStatus"> </select> </span> <input id="publishButton" type="button" value="Publish" /> <input id="cancelButton" type="button" value="Cancel" /> diff --git a/extensions/Splinter/template/en/default/pages/splinter/help.html.tmpl b/extensions/Splinter/template/en/default/pages/splinter/help.html.tmpl index 7c797c94d..3e4ca4787 100644 --- a/extensions/Splinter/template/en/default/pages/splinter/help.html.tmpl +++ b/extensions/Splinter/template/en/default/pages/splinter/help.html.tmpl @@ -25,15 +25,15 @@ <h2>Splinter Patch Review</h2> <p> - Splinter is an add-on for Bugzilla to allow conveniently + Splinter is an add-on for [% terms.Bugzilla %] to allow conveniently reviewing patches that people have attached to - Bugzilla. <a href="http://fishsoup.net/software/splinter">More + [% terms.Bugzilla %]. <a href="http://fishsoup.net/software/splinter">More information about Splinter</a>. </p> <h3>The patch review view</h3> <p> If you get to Splinter by clicking on a link next to an - attachment in Bugzilla, you are presented with the patch + attachment in [% terms.Bugzilla %], you are presented with the patch review view. This view has a number of different pages that can be switched between with the links at the top of the screen. The first page is the Overview page, the other pages correspond to @@ -69,31 +69,31 @@ </p> <ul> <li> - An overall comment. The text area on the first page allows - you to enter your overall thoughts on the bug. + An overall comment. The text area on the first page allows + you to enter your overall thoughts on the [% terms.bug %]. </li> <li> - Detailed comments on changes within the files. To comment on a - line in a patch, double click on it, and a text area will open - beneath that comment. When you are done, click the Save button - to save your comment or the Cancel button to throw your - comment away. You can double-click on a saved comment to start - editing it again and make further changes. + Detailed comments on changes within the files. To comment on a + line in a patch, double click on it, and a text area will open + beneath that comment. When you are done, click the Save button + to save your comment or the Cancel button to throw your + comment away. You can double-click on a saved comment to start + editing it again and make further changes. </li> <li> - A change to the attachment status. (This is specific to - Bugzilla instances that have attachment status, which is a - non-upstream patch. It's somewhat similar to attachment flags, - which splinter doesn't currently support displaying or - changing.) This allows you to mark a patch as read to commit - or needing additional work. This is done by changing the - drop-down next to the Publish button. + A change to the attachment status. (This is specific to + [% terms.Bugzilla %] instances that have attachment status, which is a + non-upstream patch. It's somewhat similar to attachment flags, + which splinter doesn't currently support displaying or + changing.) This allows you to mark a patch as read to commit + or needing additional work. This is done by changing the + drop-down next to the Publish button. </li> </ul> <p> Once you are done writing your review, go back to Overview page and click the "Publish" button to submit it as a comment on the - bug. The comment will have a link back to the review page so + [% terms.bug %]. The comment will have a link back to the review page so that people can see your comments with the full context. </p> <h3>Saved drafts</h3> @@ -122,31 +122,31 @@ <h3>Uploading patches for review</h3> <p> Splinter doesn't really care how patches are provided to - Bugzilla, as long as they are well-formatted patches. If you are + [% terms.Bugzilla %], as long as tmey are well-formatted patches. If you are using Git for version control, you can either format changes as patches using <a href="http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html">'git - format-patch</a> and attach them manually to the bug, or you + format-patch</a> and attach them manually to the [% terms.bug %], or you can use <a href="http://fishsoup.net/software/git-bz">git-bz</a>. git-bz is highly recommended; it automates most of the steps - that Splinter can't handle: it files new bugs, attaches updated - attachments to existing bugs, and closes bugs when you push the + that Splinter can't handle: it files new [% terms.bugs %], attaches updated + attachments to existing [% terms.bugs %], and closes [% terms.bugs %] when you push the corresponding git commits to your central repository. </p> -<h3>The bug review view</h3> +<h3>The [% terms.bug %] review view</h3> <p> Splinter also has a view where it shows all patches attached to - the bug with their status and links to review them. You are + the [% terms.bug %] with their status and links to review them. You are taken to this page after publishing a review. You can also get - to this page with the bug link in the upper-right corner of the + to this page with the [% terms.bug %] link in the upper-right corner of the patch review view. </p> <h3>Your reviews</h3> <p> Splinter can also show you a list of all your draft and published reviews. Access this page with the "Your reviews" - link at the bottom of the bug review view. In-progress drafts + link at the bottom of the [% terms.bug %] review view. In-progress drafts are shown in bold. </p> 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))); |