$xml .= add_XML_value("buildtime", date("D, d M Y H:i:s T", strtotime($build_array["starttime"] . " UTC"))); $xml .= "</build>"; $xml .= "<updates>"; // Return the status $status_array = pdo_fetch_array(pdo_query("SELECT status,revision,priorrevision,path\n FROM buildupdate,build2update AS b2u WHERE buildupdate.id=b2u.updateid AND b2u.buildid='{$buildid}'")); if (strlen($status_array["status"]) > 0 && $status_array["status"] != "0") { $xml .= add_XML_value("status", $status_array["status"]); } else { $xml .= add_XML_value("status", ""); // empty status } $xml .= add_XML_value("revision", $status_array["revision"]); $xml .= add_XML_value("priorrevision", $status_array["priorrevision"]); $xml .= add_XML_value("path", $status_array["path"]); $xml .= add_XML_value("revisionurl", get_revision_url($projectid, $status_array["revision"], $status_array["priorrevision"])); $xml .= add_XML_value("revisiondiff", get_revision_url($projectid, $status_array["priorrevision"], '')); // no prior prior revision... $xml .= "<javascript>"; $updatedfiles = pdo_query("SELECT * FROM updatefile AS uf,build2update AS b2u WHERE uf.updateid=b2u.updateid AND b2u.buildid=" . $buildid . "\n ORDER BY REVERSE(RIGHT(REVERSE(filename),LOCATE('/',REVERSE(filename)))) "); function sort_array_by_directory($a, $b) { return $a > $b ? 1 : 0; } function sort_array_by_filename($a, $b) { // Extract directory $filenamea = $a['filename']; $filenameb = $b['filename']; return $filenamea > $filenameb ? 1 : 0; } $directoryarray = array();
$build_response = array(); // Find the repository revision $update_response = array(); // Return the status $status_array = pdo_fetch_array(pdo_query("SELECT status,revision,priorrevision,path\n FROM buildupdate,build2update AS b2u\n WHERE b2u.updateid=buildupdate.id\n AND b2u.buildid='{$buildid}'")); if (strlen($status_array['status']) > 0 && $status_array['status'] != '0') { $update_response['status'] = $status_array['status']; } else { $update_response['status'] = ''; // empty status } $update_response['revision'] = $status_array['revision']; $update_response['priorrevision'] = $status_array['priorrevision']; $update_response['path'] = $status_array['path']; $update_response['revisionurl'] = get_revision_url($projectid, $status_array['revision'], $status_array['priorrevision']); $update_response['revisiondiff'] = get_revision_url($projectid, $status_array['priorrevision'], ''); // no prior prior revision... $build_response['update'] = $update_response; $build_response['site'] = $row['sitename']; $build_response['buildName'] = $row['name']; $build_response['buildStamp'] = $row['stamp']; $build_response['time'] = $row['time']; $buildLink = "viewTest.php?buildid={$buildid}"; $build_response['buildid'] = $buildid; $build_response['buildLink'] = $buildLink; $testid = $row['testid']; $testLink = "testDetails.php?test={$testid}&build={$buildid}"; $build_response['testLink'] = $testLink; switch ($row['status']) { case 'passed': $build_response['status'] = 'Passed';
function get_updates_xml_from_commits($projectname, $projectid, $dates, $commits) { $xml = "<updates>\n"; $xml .= "<timestamp>" . date(FMT_DATETIMETZ, $dates['nightly-0']) . "</timestamp>"; // Get revision numbers for the current day and "the last time it ran before that..." // Only works if the LIMIT 2 query below returns exactly 2 records and the date from // the most recent record matches the current 'nightly-0' date... If those criteria // are not met, the revision strings will be empty and no revision information will // be displayed on the resulting web page. // $revision_current = ''; $revision_prior = ''; $qry = "SELECT date, revision FROM dailyupdate " . "WHERE projectid='{$projectid}' " . " AND date <= '" . gmdate(FMT_DATE, $dates['nightly-0']) . "' " . "ORDER BY date DESC LIMIT 2"; $rows = pdo_all_rows_query($qry); if (count($rows) == 2) { if ($rows[0]['date'] == gmdate(FMT_DATE, $dates['nightly-0'])) { $revision_current = $rows[0]['revision']; $revision_prior = $rows[1]['revision']; } } $xml .= add_XML_value("revision", $revision_current); $xml .= add_XML_value("priorrevision", $revision_prior); $xml .= add_XML_value("revisionurl", get_revision_url($projectid, $revision_current, $revision_prior)); $xml .= add_XML_value("revisiondiff", get_revision_url($projectid, $revision_prior, '')); // no prior prior revision... $xml .= "<javascript>\n"; // Args to dbAdd : "true" means directory, "false" means file // $xml .= "dbAdd(true, \"Updated files (" . count($commits) . ")\", \"\", 0, \"\", \"1\", \"\", \"\", \"\", \"\", \"\")\n"; $previousdir = ""; usort($commits, "sort_by_directory_file_time"); $projecturl = get_project_property($projectname, "cvsurl"); foreach ($commits as $commit) { $directory = $commit['directory']; if ($directory != $previousdir) { $xml .= "dbAdd(true, \"" . $directory . "\", \"\", 1, \"\", \"1\", \"\", \"\", \"\", \"\", \"\")\n"; $previousdir = $directory; } $filename = $commit['filename']; $revision = ''; if ($commit['priorrevision'] != "-1") { $revision = $commit['revision']; } $time = gmdate(FMT_DATETIME, strtotime($commit['time'])); $author = $commit['author']; // Only display email if the user is logged in if (isset($_SESSION['cdash'])) { if (isset($commit['email'])) { $email = $commit['email']; } else { $email = get_author_email($projectname, $author); } } else { // If the author is an email (git for instance) we remove everything after the @ $posat = strpos($author, '@'); if ($posat !== false) { $author = substr($author, 0, $posat); } $email = ""; } $comment = $commit['comment']; $comment = str_replace("\n", " ", $comment); // Do this twice so that <something> ends up as // &lt;something&gt; because it gets sent to a // java script function not just displayed as html $comment = XMLStrFormat($comment); $comment = XMLStrFormat($comment); $diff_url = get_diff_url(get_project_id($projectname), $projecturl, $directory, $filename, $revision); $diff_url = XMLStrFormat($diff_url); $xml .= "dbAdd(false, \"" . $filename . " Revision: " . $revision . "\",\"" . $diff_url . "\",2,\"\",\"1\",\"" . $author . "\",\"" . $email . "\",\"" . $comment . "\",\"" . $commit['bugurl'] . "\",\"" . $commit['bugid'] . "\",\"" . $commit['bugpos'] . "\")\n"; } $xml .= "</javascript>\n"; $xml .= "</updates>"; return $xml; }
$xml .= add_XML_value('buildtime', date('D, d M Y H:i:s T', strtotime($build_array['starttime'] . ' UTC'))); $xml .= '</build>'; $xml .= '<updates>'; // Return the status $status_array = pdo_fetch_array(pdo_query("SELECT status,revision,priorrevision,path\n FROM buildupdate,build2update AS b2u WHERE buildupdate.id=b2u.updateid AND b2u.buildid='{$buildid}'")); if (strlen($status_array['status']) > 0 && $status_array['status'] != '0') { $xml .= add_XML_value('status', $status_array['status']); } else { $xml .= add_XML_value('status', ''); // empty status } $xml .= add_XML_value('revision', $status_array['revision']); $xml .= add_XML_value('priorrevision', $status_array['priorrevision']); $xml .= add_XML_value('path', $status_array['path']); $xml .= add_XML_value('revisionurl', get_revision_url($projectid, $status_array['revision'], $status_array['priorrevision'])); $xml .= add_XML_value('revisiondiff', get_revision_url($projectid, $status_array['priorrevision'], '')); // no prior prior revision... $xml .= '<javascript>'; $updatedfiles = pdo_query('SELECT * FROM updatefile AS uf,build2update AS b2u WHERE uf.updateid=b2u.updateid AND b2u.buildid=' . $buildid . "\n ORDER BY REVERSE(RIGHT(REVERSE(filename),LOCATE('/',REVERSE(filename)))) "); function sort_array_by_directory($a, $b) { return $a > $b ? 1 : 0; } function sort_array_by_filename($a, $b) { // Extract directory $filenamea = $a['filename']; $filenameb = $b['filename']; return $filenamea > $filenameb ? 1 : 0; } $directoryarray = array();