$file['bugid'] = $bug[1]; $file['bugpos'] = $bug[2]; } if ($status == "UPDATED") { $diff_url = get_diff_url($projectid, $projecturl, $directory, $filename, $revision); $diff_url = XMLStrFormat($diff_url); $file['diff_url'] = $diff_url; $updatedfiles[] = $file; } else { if ($status == "MODIFIED") { $diff_url = get_diff_url($projectid, $projecturl, $directory, $filename); $diff_url = XMLStrFormat($diff_url); $file['diff_url'] = $diff_url; $locallymodified[] = $file; } else { $diff_url = get_diff_url($projectid, $projecturl, $directory, $filename); $diff_url = XMLStrFormat($diff_url); $file['diff_url'] = $diff_url; $conflictingfiles[] = $file; } } } // Updated files $xml .= "dbAdd (true, \"" . $projectname . " Updated files (" . count($updatedfiles) . ")\", \"\", 0, \"\", \"1\", \"\", \"\", \"\", \"\", \"\", \"\")\n"; $previousdir = ""; foreach ($updatedfiles as $file) { $directory = $file['directory']; if ($previousdir == "" || $directory != $previousdir) { $xml .= " dbAdd (true, \"" . $directory . "\", \"\", 1, \"\", \"1\", \"\", \"\", \"\", \"\", \"\", \"\")\n"; $previousdir = $directory; }
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; }
if ($i == 0) { $error_response['argumentfirst'] = $argument_array['argument']; } else { $arguments_response[] = $argument_array['argument']; } $i++; } $error_response['arguments'] = $arguments_response; get_labels_JSON_from_query_results("SELECT text FROM label, label2buildfailure\n WHERE label.id=label2buildfailure.labelid AND\n label2buildfailure.buildfailureid='{$buildfailureid}'\n ORDER BY text ASC", $error_response); $stderror = $error_array['stderror']; $stdoutput = $error_array['stdoutput']; if (isset($error_array['sourcefile'])) { $projectCvsUrl = $project_array['cvsurl']; $file = basename($error_array['sourcefile']); $directory = dirname($error_array['sourcefile']); $cvsurl = get_diff_url($projectid, $projectCvsUrl, $directory, $file, $revision); $error_response['cvsurl'] = $cvsurl; $source_dir = get_source_dir($projectid, $projectCvsUrl, $directory); if ($source_dir !== NULL) { $stderror = linkify_compiler_output($projectCvsUrl, $source_dir, $revision, $stderror); $stdoutput = linkify_compiler_output($projectCvsUrl, $source_dir, $revision, $stdoutput); } } if ($stderror) { $error_response['stderror'] = $stderror; } if ($stdoutput) { $error_response['stdoutput'] = $stdoutput; } $error_response['exitcondition'] = $error_array['exitcondition']; $errorid++;
/** * Marshals the data of a particular build error into a serializable * friendly format. * * Requires the $data of a build error, the $project, and the buildupdate.revision. **/ public static function marshal($data, $project, $revision) { // Sets up access to $file and $directory extract(self::GetSourceFile($data)); $marshaled = array('new' => isset($data['newstatus']) ? $data['newstatus'] : -1, 'logline' => $data['logline'], 'cvsurl' => get_diff_url($project['id'], $project['cvsurl'], $directory, $file, $revision)); $marshaled = array_merge($marshaled, array('precontext' => linkify_compiler_output($marshaled['cvsurl'], "/\\.\\.\\.", $revision, $data['precontext']), 'text' => linkify_compiler_output($marshaled['cvsurl'], "/\\.\\.\\.", $revision, $data['text']), 'postcontext' => linkify_compiler_output($marshaled['cvsurl'], "/\\.\\.\\.", $revision, $data['postcontext']), 'sourcefile' => $data['sourcefile'], 'sourceline' => $data['sourceline'])); if (isset($data['subprojectid'])) { $marshaled['subprojectid'] = $data['subprojectid']; $marshaled['subprojectname'] = $data['subprojectname']; } return $marshaled; }
/** * Marshal a build failure, this includes the build failure arguments. **/ public static function marshal($data, $project, $revision, $linkifyOutput = false) { $marshaled = array_merge(array('language' => $data['language'], 'sourcefile' => $data['sourcefile'], 'targetname' => $data['targetname'], 'outputfile' => $data['outputfile'], 'outputtype' => $data['outputtype'], 'workingdirectory' => $data['workingdirectory'], 'exitcondition' => $data['exitcondition']), self::GetBuildFailureArguments($data['id'])); $marshaled['stderror'] = $data['stderror']; $marshaled['stdoutput'] = $data['stdoutput']; if (isset($data['sourcefile'])) { $file = basename($data['sourcefile']); $directory = dirname($data['sourcefile']); $marshaled['cvsurl'] = get_diff_url($project['id'], $project['cvsurl'], $directory, $file, $revision); $source_dir = get_source_dir($project['id'], $project['cvsurl'], $directory); if ($source_dir !== null && $linkifyOutput) { $marshaled['stderror'] = linkify_compiler_output($project['cvsurl'], $source_dir, $revision, $data['stderror']); $marshaled['stdoutput'] = linkify_compiler_output($project['cvsurl'], $source_dir, $revision, $data['stdoutput']); } } if (isset($data['subprojectid'])) { $marshaled['subprojectid'] = $data['subprojectid']; $marshaled['subprojectname'] = $data['subprojectname']; } return $marshaled; }