xaizek / uncov (License: AGPLv3+) (since 2018-12-07)
Uncov(er) is a tool that collects and processes code coverage reports.
Commit a1d649171082f5fa3e040c537ad10e3cad5d8e69

Add "build-count" configuration option
It specifies number of builds to show by default. When unspecified, the
behaviour is backwards compatible.

Affects `uncov builds` and lists of builds of uncov-web (useful for
reducing load from bots).
Author: xaizek
Author date (UTC): 2026-07-20 16:31
Committer name: xaizek
Committer date (UTC): 2026-07-20 16:31
Parent(s): 027891ed616150cbbe4d2be457df172395ea035a
Signing key: 99DC5E4DB05F6BE2
Tree: 16517593d70040be024e5caf465385a3ebef6432
File Lines added Lines deleted
docs/uncov.1 6 0
docs/uncov/07-configuration.md 4 0
src/Settings.cpp 7 0
src/Settings.hpp 19 0
src/sub_commands.cpp 2 2
tests/Settings.cpp 5 1
tests/test-configs/correct.ini 1 0
tests/test-configs/default.ini 1 0
tests/test-configs/incorrect.ini 1 0
tests/test-configs/out-of-range.ini 1 0
web/WebSettings.hpp 1 0
web/builds.ecpp 10 0
web/style.css 4 0
File docs/uncov.1 changed (mode: 100644) (index 29a03a3..2444c26)
... ... Number of visible lines above and below changes.
480 480 \f[B]uncov\-web\f[R]: true) \f[B]uncov\-web\f[R]: true)
481 481 .PP .PP
482 482 Whether line numbers are displayed in diffs. Whether line numbers are displayed in diffs.
483 .PP
484 \f[B]build\-count\f[R] (integer, \f[B]uncov\f[R]: 10,
485 \f[B]uncov\-web\f[R]: 0)
486 .PP
487 Number of builds to show by default.
488 The value of zero means \(lqunlimited\(rq.
483 489 .SH FILES .SH FILES
484 490 \f[B]<data\-directory>\f[R] in the following is either git\-directory \f[B]<data\-directory>\f[R] in the following is either git\-directory
485 491 for a worktree (see \f[B]git\-worktree\f[R](1)) or for the repository for a worktree (see \f[B]git\-worktree\f[R](1)) or for the repository
File docs/uncov/07-configuration.md changed (mode: 100644) (index 3f8fc4c..5e144d9)
... ... Number of visible lines above and below changes.
48 48 **diff-show-lineno** (boolean, **uncov**: false, **uncov-web**: true) **diff-show-lineno** (boolean, **uncov**: false, **uncov-web**: true)
49 49
50 50 Whether line numbers are displayed in diffs. Whether line numbers are displayed in diffs.
51
52 **build-count** (integer, **uncov**: 10, **uncov-web**: 0)
53
54 Number of builds to show by default. The value of zero means "unlimited".
File src/Settings.cpp changed (mode: 100644) (index e6b5927..ff5b9e8)
... ... Settings::loadFromFile(const std::string &path)
44 44 setMinFoldSize(props.get<int>("min-fold-size", minFoldSize)); setMinFoldSize(props.get<int>("min-fold-size", minFoldSize));
45 45 foldContext = props.get<int>("fold-context", foldContext); foldContext = props.get<int>("fold-context", foldContext);
46 46 setPrintLineNoInDiff(props.get<bool>("diff-show-lineno", diffShowLineNo)); setPrintLineNoInDiff(props.get<bool>("diff-show-lineno", diffShowLineNo));
47 setBuildCount(props.get<int>("build-count", buildCount));
47 48
48 49 medLimit = std::max(0.0f, std::min(100.0f, medLimit)); medLimit = std::max(0.0f, std::min(100.0f, medLimit));
49 50 hiLimit = std::max(0.0f, std::min(100.0f, hiLimit)); hiLimit = std::max(0.0f, std::min(100.0f, hiLimit));
 
... ... Settings::setPrintLineNoInDiff(bool value)
66 67 { {
67 68 diffShowLineNo = value; diffShowLineNo = value;
68 69 } }
70
71 void
72 Settings::setBuildCount(int value)
73 {
74 buildCount = std::max(0, value);
75 }
File src/Settings.hpp changed (mode: 100644) (index 4c560fa..562bb6b)
... ... public:
40 40 // Loads some of the settings from file. Does nothing if it doesn't exist. // Loads some of the settings from file. Does nothing if it doesn't exist.
41 41 void loadFromFile(const std::string &path); void loadFromFile(const std::string &path);
42 42
43 /**
44 * @brief Retrieves number of builds to show by default.
45 *
46 * @returns The number, which is 0 when there is no limit.
47 */
48 virtual int getBuildCount() const
49 {
50 return buildCount;
51 }
52
43 53 public: // PrintingSettings only public: // PrintingSettings only
44 54 virtual std::string getTimeFormat() const override virtual std::string getTimeFormat() const override
45 55 { {
 
... ... protected:
104 114 */ */
105 115 void setPrintLineNoInDiff(bool value); void setPrintLineNoInDiff(bool value);
106 116
117 /**
118 * @brief Sets number of builds to show by default.
119 *
120 * @param value New value of the limit, use 0 for "unlimited".
121 */
122 void setBuildCount(int value);
123
107 124 private: private:
108 125 //! Percentage boundary between low and medium coverage. //! Percentage boundary between low and medium coverage.
109 126 float medLimit = 70.0f; float medLimit = 70.0f;
 
... ... private:
117 134 bool diffShowLineNo = false; bool diffShowLineNo = false;
118 135 //! Number of visible lines above and below interesting lines. //! Number of visible lines above and below interesting lines.
119 136 int foldContext = 1; int foldContext = 1;
137 //! Number of builds to show by default, 0 means "unlimited".
138 int buildCount = 10;
120 139 }; };
121 140
122 141 #endif // UNCOV_SETTINGS_HPP_ #endif // UNCOV_SETTINGS_HPP_
File src/sub_commands.cpp changed (mode: 100644) (index 33a34d8..7b7390a)
... ... private:
334 334 execImpl(const std::string &alias, execImpl(const std::string &alias,
335 335 const std::vector<std::string> &args) override const std::vector<std::string> &args) override
336 336 { {
337 // By default limit number of builds to display to 10.
337 // By default limit number of builds to a configurable number.
338 338 bool limitBuilds = true; bool limitBuilds = true;
339 unsigned int maxBuildCount = 10;
339 unsigned int maxBuildCount = settings->getBuildCount();
340 340 if (tryParse(args, noArgsForm{})) { if (tryParse(args, noArgsForm{})) {
341 341 // Nothing needs to be done, variable defaults are getting used. // Nothing needs to be done, variable defaults are getting used.
342 342 } else if (auto parsed = tryParse(args, limitForm{})) { } else if (auto parsed = tryParse(args, limitForm{})) {
File tests/Settings.cpp changed (mode: 100644) (index a58e47c..989237e)
... ... operator==(const Settings &lhs, const Settings &rhs)
29 29 && lhs.printLineNoInDiff() == rhs.printLineNoInDiff() && lhs.printLineNoInDiff() == rhs.printLineNoInDiff()
30 30 && lhs.getMinFoldSize() == rhs.getMinFoldSize() && lhs.getMinFoldSize() == rhs.getMinFoldSize()
31 31 && lhs.getFoldContext() == rhs.getFoldContext() && lhs.getFoldContext() == rhs.getFoldContext()
32 && lhs.isHtmlOutput() == rhs.isHtmlOutput();
32 && lhs.isHtmlOutput() == rhs.isHtmlOutput()
33 && lhs.getBuildCount() == rhs.getBuildCount();
33 34 } }
34 35
35 36 TEST_CASE("Loading from nonexistent file doesn't change anything", "[Settings]") TEST_CASE("Loading from nonexistent file doesn't change anything", "[Settings]")
 
... ... TEST_CASE("Settings from correct config are applied", "[Settings]")
61 62 CHECK(settings.getTabSize() == 4); CHECK(settings.getTabSize() == 4);
62 63 CHECK(settings.getMinFoldSize() == 3); CHECK(settings.getMinFoldSize() == 3);
63 64 CHECK(settings.getFoldContext() == 1); CHECK(settings.getFoldContext() == 1);
65 CHECK(settings.getBuildCount() == 10);
64 66 CHECK(!settings.printLineNoInDiff()); CHECK(!settings.printLineNoInDiff());
65 67
66 68 settings.loadFromFile("tests/test-configs/correct.ini"); settings.loadFromFile("tests/test-configs/correct.ini");
 
... ... TEST_CASE("Settings from correct config are applied", "[Settings]")
69 71 CHECK(settings.getTabSize() == 2); CHECK(settings.getTabSize() == 2);
70 72 CHECK(settings.getMinFoldSize() == 4); CHECK(settings.getMinFoldSize() == 4);
71 73 CHECK(settings.getFoldContext() == 3); CHECK(settings.getFoldContext() == 3);
74 CHECK(settings.getBuildCount() == 13);
72 75 CHECK(settings.printLineNoInDiff()); CHECK(settings.printLineNoInDiff());
73 76 } }
74 77
 
... ... TEST_CASE("Invalid values are handled sensibly", "[Settings]")
104 107 CHECK(settings.getTabSize() == 1); CHECK(settings.getTabSize() == 1);
105 108 CHECK(settings.getMinFoldSize() == 1); CHECK(settings.getMinFoldSize() == 1);
106 109 CHECK(settings.getFoldContext() == 0); CHECK(settings.getFoldContext() == 0);
110 CHECK(settings.getBuildCount() == 0);
107 111 } }
108 112 } }
File tests/test-configs/correct.ini changed (mode: 100644) (index 8d4ef31..b282128)
... ... tab-size = 2
5 5 min-fold-size = 4 min-fold-size = 4
6 6 fold-context = 3 fold-context = 3
7 7 diff-show-lineno = true diff-show-lineno = true
8 build-count = 13
File tests/test-configs/default.ini changed (mode: 100644) (index 3674de1..f650748)
... ... tab-size = 4
4 4 min-fold-size = 3 min-fold-size = 3
5 5 fold-context = 1 fold-context = 1
6 6 diff-show-lineno = false diff-show-lineno = false
7 build-count = 10
File tests/test-configs/incorrect.ini changed (mode: 100644) (index 6e46e7e..ce2d7d2)
... ... tab-size = two
4 4 min-fold-size = four min-fold-size = four
5 5 fold-context = three fold-context = three
6 6 diff-show-lineno = truth diff-show-lineno = truth
7 build-count = ten
File tests/test-configs/out-of-range.ini changed (mode: 100644) (index 85216c1..a80a89c)
... ... hi-bound = 124
3 3 tab-size = -4 tab-size = -4
4 4 min-fold-size = -3 min-fold-size = -3
5 5 fold-context = -1 fold-context = -1
6 build-count = -1
File web/WebSettings.hpp changed (mode: 100644) (index a9f6985..a34c3de)
... ... public:
26 26 { {
27 27 setMinFoldSize(4); setMinFoldSize(4);
28 28 setPrintLineNoInDiff(true); setPrintLineNoInDiff(true);
29 setBuildCount(0);
29 30 } }
30 31
31 32 public: // FilePrinterSettings only public: // FilePrinterSettings only
File web/builds.ecpp changed (mode: 100644) (index 6c09310..19f076e)
... ... along with uncov. If not, see <http://www.gnu.org/licenses/>.
24 24 #include <boost/range/adaptor/reversed.hpp> #include <boost/range/adaptor/reversed.hpp>
25 25
26 26 #include "BuildHistory.hpp" #include "BuildHistory.hpp"
27 #include "Settings.hpp"
27 28 #include "listings.hpp" #include "listings.hpp"
28 29
29 30 extern BuildHistory *globalBH; extern BuildHistory *globalBH;
31 extern Settings *globalSettings;
30 32 </%pre> </%pre>
31 33
32 34 <%cpp> <%cpp>
 
... ... along with uncov. If not, see <http://www.gnu.org/licenses/>.
81 83 % ? globalBH->getBuilds() % ? globalBH->getBuilds()
82 84 % : globalBH->getBuildsOn(branch); % : globalBH->getBuildsOn(branch);
83 85 % namespace adaptors = boost::adaptors; % namespace adaptors = boost::adaptors;
86 % const unsigned int maxBuildCount = globalSettings->getBuildCount();
87 % unsigned int i = 0;
84 88 % for (const Build &build : adaptors::reverse(builds)) { % for (const Build &build : adaptors::reverse(builds)) {
85 89 <tr> <tr>
86 90 % const std::vector<std::string> descr = describeBuild(globalBH, build, % const std::vector<std::string> descr = describeBuild(globalBH, build,
 
... ... along with uncov. If not, see <http://www.gnu.org/licenses/>.
105 109 </div> </div>
106 110 </td> </td>
107 111 </tr> </tr>
112 % if (++i == maxBuildCount && builds.size() - i > 1) {
113 <tr>
114 <td class="note" colspan="6"><$ builds.size() - i $> more builds were omitted</td>
115 </tr>
116 % break;
117 % }
108 118 % } % }
109 119
110 120 </table> </table>
File web/style.css changed (mode: 100644) (index 6e55136..c893c81)
... ... td:nth-child(1), th:nth-child(1) {
82 82 text-align: left; text-align: left;
83 83 } }
84 84
85 td.note, td:nth-child(1).note {
86 text-align: center;
87 }
88
85 89 pre { pre {
86 90 line-height: 125%; line-height: 125%;
87 91 } }
Hints

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