Merge "fix hideci for new change screen"

This commit is contained in:
Jenkins 2014-10-29 18:31:09 +00:00 committed by Gerrit Code Review
commit ff55bbcbfc

View File

@ -18,7 +18,7 @@ var hashRegex = /^\#\/c\/[\/\d]+$/;
// this regex matches CI comments // this regex matches CI comments
var ciRegex = /^(.* CI|Jenkins)$/; var ciRegex = /^(.* CI|Jenkins)$/;
// this regex matches "Patch set #" // this regex matches "Patch set #"
var psRegex = /^<p>(Uploaded patch set|Patch Set) (\d+)(:|\.)/; var psRegex = /^(Uploaded patch set|Patch Set) (\d+)(:|\.)/;
// this regex matches merge failure messages // this regex matches merge failure messages
var mergeFailedRegex = /Merge Failed\./; var mergeFailedRegex = /Merge Failed\./;
// this regex matches the name of CI systems we trust to report merge failures // this regex matches the name of CI systems we trust to report merge failures
@ -26,14 +26,6 @@ var trustedCIRegex = /^(OpenStack CI|Jenkins)$/;
// this regex matches the pipeline markup // this regex matches the pipeline markup
var pipelineNameRegex = /Build \w+ \((\w+) pipeline\)/; var pipelineNameRegex = /Build \w+ \((\w+) pipeline\)/;
var ci_parse_psnum = function($panel) {
var match = psRegex.exec($panel.html());
if (match !== null) {
return parseInt(match[2]);
}
return 0;
};
var ci_parse_is_merge_conflict = function($panel) { var ci_parse_is_merge_conflict = function($panel) {
return (mergeFailedRegex.exec($panel.html()) !== null); return (mergeFailedRegex.exec($panel.html()) !== null);
}; };
@ -122,20 +114,38 @@ var ci_group_by_pipeline = function(current, comments) {
var ci_parse_comments = function() { var ci_parse_comments = function() {
var comments = []; var comments = [];
$(".commentPanel").each(function() { $("p").each(function() {
var comment = {}; var match = psRegex.exec($(this).html());
comment.name = $(this).attr("name"); if (match !== null) {
comment.email = $(this).attr("email"); var psnum = parseInt(match[2]);
comment.date = $(this).find(".commentPanelDateCell").attr("title"); var top = $(this).parent().parent().parent();
var comment_panel = $(this).find(".commentPanelMessage"); // old change screen
comment.psnum = ci_parse_psnum(comment_panel); var name = top.attr("name");
comment.merge_conflict = ci_parse_is_merge_conflict(comment_panel); if (!name) {
comment.pipeline = ci_find_pipeline(comment_panel); // new change screen
comment.results = ci_parse_results(comment_panel); name = $(this).parent().prev().children()[0].innerHTML;
comment.is_ci = (ciRegex.exec(comment.name) !== null); }
comment.is_trusted_ci = (trustedCIRegex.exec(comment.name) !== null); var comment = {};
comment.ref = this; comment.name = name;
comments.push(comment);
var date_cell = top.find(".commentPanelDateCell");
if (date_cell.attr("title")) {
// old change screen
comment.date = date_cell.attr("title");
} else {
// new change screen
comment.date = $(this).parent().prev().children()[2].innerHTML;
}
var comment_panel = $(this).parent();
comment.psnum = psnum;
comment.merge_conflict = ci_parse_is_merge_conflict(comment_panel);
comment.pipeline = ci_find_pipeline(comment_panel);
comment.results = ci_parse_results(comment_panel);
comment.is_ci = (ciRegex.exec(comment.name) !== null);
comment.is_trusted_ci = (trustedCIRegex.exec(comment.name) !== null);
comment.ref = top;
comments.push(comment);
}
}); });
return comments; return comments;
}; };