<!--
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 the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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 <boost/optional.hpp>
#include <tnt/httperror.h>
#include "BuildHistory.hpp"
#include "FilePrinter.hpp"
#include "Repository.hpp"
#include "WebSettings.hpp"
#include "listings.hpp"
#include "utils.hpp"
extern Repository *globalRepo;
extern BuildHistory *globalBH;
</%pre>
<%cpp>
const int buildId = [&request]() {
try {
return std::stoi(request.getArg("buildId"));
} 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(WebSettings());
</%application>
<html>
<head>
<title><$ filePath $> of build #<$ buildId $> | 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/<$ build->getId() $>">Current build</a>
<br/>
<a class="action" href="/changes/<$ buildId $>">Changed files</a>
<a class="action" href="/changes/<$ buildId $>/<$ 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>
<%include>web/footer.ecpp</%include>
</div>
<h4>
Path: <a class="path" href="/builds/<$ 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/<$ 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); ) {
<a name="l<$++line$>"></a><$$ s $>
% }
</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