<!--
Copyright (C) 2017 xaizek <xaizek@posteo.net>
This file is part of uncov.
uncov is free software: you can redistribute it and/or modify
it under the terms of version 3 of the GNU Affero General Public License as
published by the Free Software Foundation.
uncov is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with uncov. If not, see <http://www.gnu.org/licenses/>.
-->
<%pre>
#include <string>
#include <boost/optional.hpp>
#include <tnt/httperror.h>
#include "utils/strings.hpp"
#include "BuildHistory.hpp"
#include "FilePrinter.hpp"
#include "Repository.hpp"
#include "Settings.hpp"
#include "listings.hpp"
extern Repository *globalRepo;
extern BuildHistory *globalBH;
extern Settings *globalSettings;
</%pre>
<%cpp>
const std::string buildIdStr = request.getArg("buildId");
const int buildId = [&request, &buildIdStr]() {
try {
return std::stoi(buildIdStr);
} catch (const std::exception &) {
return 0;
}
}();
const std::string filePath = request.getArg("filePath");
</%cpp>
<%application>
// srchilite::SourceHighlight doesn't seem to be thread safe (in particular
// it has grammar parsing with global state) and needs to be globally
// locked
FilePrinter printer(*globalSettings);
</%application>
<html>
<head>
<title><$ filePath $> of build #<$ buildIdStr $> | uncov</title>
<%include>web/header.ecpp</%include>
</head>
<body>
% if (boost::optional<Build> build = globalBH->getBuild(buildId)) {
% if (boost::optional<File &> file = build->getFile(filePath)) {
% std::vector<std::string> fileInfo = describeFile(globalBH, *build, *file,
% DoSpacing{});
% std::vector<std::string> buildInfo = describeBuild(globalBH, *build,
% !DoExtraAlign{},
% DoSpacing{});
<div class="sidenav">
<a href="/builds">All builds</a>
<a href="/branches/<$ buildInfo[5] $>">Current branch</a>
<a href="/builds/<$ std::to_string(build->getId()) $>">Current build</a>
<br/>
<a class="action" href="/changes/<$ buildIdStr $>">Changed files</a>
<a class="action" href="/changes/<$ buildIdStr $>/<$ filePath $>">Changes</a>
</div>
<div class="rightbar">
<div class="bargroup">
<span class="barelem">Build <$$ buildInfo[0] $></span>
<span class="barelem"><$$ buildInfo[1] $></br>
<small><$$ buildInfo[2] $></small></span>
<span class="barelem"><$$ buildInfo[3] $></br>
<small><$$ buildInfo[4] $></small></span>
<span class="barelem">
<div class="tooltip">
<span class="tooltipobj">
<a class="branch" href="/branches/<$ buildInfo[5] $>">
<$$ buildInfo[5] $>
</a>
</span>
<span class="tooltiptext">
<$$ buildInfo[6] $>
</span>
</div>
</span>
</div>
<div class="bargroup">
<span class="barelem">File</span>
<span class="barelem"><$$ fileInfo[1] $></br>
<small><$$ fileInfo[2] $></small></span>
<span class="barelem"><$$ fileInfo[3] $></br>
<small><$$ fileInfo[4] $></small></span>
</div>
% if (file->getMissedCount() > 0) {
<div class="bargroup">
<span class="barelem">Missed</span>
<div class="barmap">
<table class="maptable">
% int runLength = 0;
% int runStart;
% bool covered = false;
% auto spawnRun = [&]() {
% if (!covered && runLength != 0) {
<tr onclick="document.location = '#l<$ std::to_string(runStart) $>'">
<td class="line">
<a href="#l<$ std::to_string(runStart) $>">
<div><$ std::to_string(runStart) $>.</div>
</a>
</td>
<td class="missedcount">
<a href="#l<$ std::to_string(runStart) $>">
<div><$ runLength $></div>
</a>
</td>
</tr>
% }
% };
% int lnum = 0;
% for (int c : file->getCoverage()) {
% ++lnum;
% if (c < 0) {
% continue;
% }
% if (runLength > 0 && (c > 0) == covered) {
% ++runLength;
% } else {
% spawnRun();
% covered = (c > 0);
% runLength = 1;
% runStart = lnum;
% }
% }
% spawnRun();
</table>
</div>
</div>
% }
<%include>web/footer.ecpp</%include>
</div>
<h4>
Path: <a class="path" href="/builds/<$ std::to_string(build->getId()) $>"><root></a>
% std::string pathPrefix;
% for (const std::string &entry : split(fileInfo[0], '/')) {
% pathPrefix += '/' + entry;
% const std::string slash = pathPrefix == "/" + fileInfo[0] ? "" : "/";
/ <a class="path"
href="/builds/<$ std::to_string(build->getId()) $><$ pathPrefix + slash $>"><$ entry $></a>
% }
</h4>
%// TODO: add links to file lines (currently we have only anchors)
% const std::string &path = file->getPath();
% const std::string &ref = build->getRef();
<pre>
% std::stringstream oss;
% printer.print(oss, path, globalRepo->readFile(ref, path),
% file->getCoverage());
% int line = 0;
% for (std::string s; std::getline(oss, s); ) {
<span id="l<$std::to_string(++line)$>" class="line"><$$ s $></span>
% }
</pre>
% } else {
% log_warn("Can't find requested file " + filePath + " in build #"
% + std::to_string(buildId));
<h1>No such file</h1>
% }
% } else {
% log_warn("Can't find requested build #" + std::to_string(buildId));
<h1>No such build</h1>
% }
</body>
</html>
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/uncov
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/uncov
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master