improve headings in separate repository view

Wed, 19 Feb 2025 18:53:18 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 19 Feb 2025 18:53:18 +0100
changeset 37
d7e9a1200e21
parent 36
e223879aa02a
child 38
f716db85d91e

improve headings in separate repository view

fixes #600

src/main.cpp file | annotate | diff | comparison | revisions
src/repositories.cpp file | annotate | diff | comparison | revisions
src/repositories.h file | annotate | diff | comparison | revisions
--- a/src/main.cpp	Wed Feb 19 18:32:17 2025 +0100
+++ b/src/main.cpp	Wed Feb 19 18:53:18 2025 +0100
@@ -235,7 +235,7 @@
     fm::heatmap heatmap;
     for (auto &&repo : repos.list()) {
         if (settings.separate) {
-            heatmap.set_repo(repo.path);
+            heatmap.set_repo(repo.name);
         }
         proc.chdir(repo.path);
         if (repo.type == fm::HG) {
--- a/src/repositories.cpp	Wed Feb 19 18:32:17 2025 +0100
+++ b/src/repositories.cpp	Wed Feb 19 18:53:18 2025 +0100
@@ -30,15 +30,21 @@
 using namespace fm;
 namespace fs = std::filesystem;
 
+repository::repository(repository_type type, std::string path) noexcept
+    : path(std::move(path)),
+      name(fs::path(this->path).filename()),
+      type(type) {
+}
+
 void repositories::scan(std::string path, unsigned depth) {
     // check the base path
     {
         auto p = fs::path{path};
         if (is_directory(p / ".hg")) {
-            m_repositories.emplace_back(repository{canonical(p), HG});
+            m_repositories.emplace_back(HG, canonical(p));
             return;
         } else if (is_directory(p / ".git")) {
-            m_repositories.emplace_back(repository{canonical(p), GIT});
+            m_repositories.emplace_back(GIT, canonical(p));
             return;
         } else if (depth == 0) {
             return;
@@ -54,10 +60,10 @@
         if (!i->is_directory()) continue;
         auto p = i->path();
         if (is_directory(p / ".hg")) {
-            m_repositories.emplace_back(repository{canonical(p), HG});
+            m_repositories.emplace_back(HG, canonical(p));
             i.disable_recursion_pending();
         } else if (is_directory(p / ".git")) {
-            m_repositories.emplace_back(repository{canonical(p), GIT});
+            m_repositories.emplace_back(GIT, canonical(p));
             i.disable_recursion_pending();
         } else if (i.depth() == depth) {
             i.disable_recursion_pending();
--- a/src/repositories.h	Wed Feb 19 18:32:17 2025 +0100
+++ b/src/repositories.h	Wed Feb 19 18:53:18 2025 +0100
@@ -36,7 +36,10 @@
 
 struct repository final {
     std::string path;
+    std::string name;
     repository_type type;
+    repository(repository_type type, std::string path) noexcept;
+    ~repository() = default;
 };
 
 class repositories final {

mercurial