botanjs/src/Astro/Build/Components/BuildReport.js
raw ยท 1667 bytes
(function(){
var ns = __namespace( "Astro.Build.Components.BuildReport" );
/** @type {System.utils.IKey} */
var IKey = __import( "System.utils.IKey" );
/** @type {Dandelion} */
var Dand = __import( "Dandelion" );
/** @type {Astro.Bootstrap} */
var Bootstrap = __import( "Astro.Bootstrap" );
/** @type {System.Debug} */
var debug = __import( "System.Debug" );
var getData = __import( "System.Net.getData" );
var init = function()
{
var commit = Dand.id( "commit-sha", true );
var putCommitMessage = function( e )
{
Dand.id( "commit-message" ).innerHTML = e || "Failed to load message";
commit.setAttribute( new IKey( "class", e ? "ok" : "failed" ) )
};
sanitizeReport();
getData( "/" + commit.getDAttribute( "project" ) + "/commit-message/" + commit.getDAttribute( "sha" ), putCommitMessage, putCommitMessage );
};
var sanitizeReport = function()
{
var buildMessage = Dand.id( "build-message" );
var message = buildMessage.innerHTML.replace( );
var sRegEx = /[\r\n]*{CI_SECTION_START}[\r\n\s]*(.*)[\r\n]*/g;
var eRegEx = /[\r\n]*{CI_SECTION_END}[\r\n]*/g;
var sCount = ( message.match( sRegEx ) || [] ).length;
if( !sCount ) return;
if( sCount != ( message.match( eRegEx ) || [] ).length )
{
debug.Error( new Error( "Section Flag count mismatch" ) );
return;
}
buildMessage.innerHTML = message
.replace( sRegEx, "<pre class=\"section\" data-name=\"$1\">" )
.replace( eRegEx, "</pre>" )
.replace( /: (failed|ok)\n/g, ": <span class=\"status $1\">$1</span>\n" )
;
};
Bootstrap.regInit( init );
})();