startgit

Static page generator for git repositories
git clone git://git.dimitrijedobrota.com/startgit.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit 80d5e3b1a3bde33e5c9ced4778267bf8a362e56c
parent 8cb2a0807d6e5e2e8be60c5ccdbd794ed4c3e444
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Fri, 24 Jan 2025 20:23:58 +0100

Special file list can be set from command line

Diffstat:
M CMakeLists.txt | + -
M source/arguments.hpp | +++++++++
M source/branch.cpp | ++++++++ ----------
M source/file.cpp | + -
M source/file.hpp | + -
M source/main.cpp | ++++++++++++

6 files changed, 32 insertions(+), 13 deletions(-)


diff --git a/ CMakeLists.txt b/ CMakeLists.txt

@@ -4,7 +4,7 @@ include(cmake/prelude.cmake) project( startgit
VERSION 0.1.32
VERSION 0.1.33
DESCRIPTION "Static page generator for git repositories" HOMEPAGE_URL "https://git.dimitrijedobrota.com/stargit.git" LANGUAGES CXX

diff --git a/ source/arguments.hpp b/ source/arguments.hpp

@@ -2,6 +2,7 @@ #include <filesystem> #include <string>
#include <unordered_set>
#include <vector> namespace startgit

@@ -16,6 +17,14 @@ struct arguments_t std::string author = "Dimitrije Dobrota"; std::string title = "Collection of git repositories"; std::string description = "Publicly available personal projects";
std::unordered_set<std::filesystem::path> special = {
"BUILDING.md",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"HACKING.md",
"LICENSE.md",
"README.md",
};
bool force = false; };

diff --git a/ source/branch.cpp b/ source/branch.cpp

@@ -1,11 +1,11 @@ #include <algorithm> #include <functional>
#include <unordered_set>
#include "branch.hpp" #include <git2wrap/revwalk.hpp>
#include "arguments.hpp"
#include "repository.hpp" namespace startgit

@@ -46,18 +46,16 @@ branch::branch(git2wrap::branch brnch, repository& repo) continue; }
static const std::unordered_set<std::filesystem::path> special {
"README.md",
"LICENSE.md",
"BUILDING.md",
"HACKING.md",
};
m_files.emplace_back(entry, full_path);
if (!path.empty() || !special.contains(entry.get_name())) {
if (!path.empty()) {
continue; }
m_special.emplace_back(entry, full_path);
auto itr = args.special.find(entry.get_name());
if (itr != args.special.end()) {
m_special.emplace_back(entry, *itr);
}
} };

diff --git a/ source/file.cpp b/ source/file.cpp

@@ -10,7 +10,7 @@ namespace startgit {
file::file(const git2wrap::tree_entry& entry, std::string path)
file::file(const git2wrap::tree_entry& entry, std::filesystem::path path)
: m_filemode(filemode(entry.get_filemode())) , m_path(std::move(path)) , m_blob(

diff --git a/ source/file.hpp b/ source/file.hpp

@@ -12,7 +12,7 @@ namespace startgit class file { public:
file(const git2wrap::tree_entry& entry, std::string path);
file(const git2wrap::tree_entry& entry, std::filesystem::path path);
std::string get_filemode() const { return m_filemode; } std::filesystem::path get_path() const { return m_path; }

diff --git a/ source/main.cpp b/ source/main.cpp

@@ -748,6 +748,17 @@ int parse_opt(int key, const char* arg, poafloc::Parser* parser) case 'f': l_args->force = true; break;
case 's': {
std::stringstream sstream(arg);
std::string crnt;
l_args->special.clear();
while (std::getline(sstream, crnt, ',')) {
l_args->special.emplace(crnt);
}
break;
}
case poafloc::ARG: try { l_args->repos.emplace_back(std::filesystem::canonical(arg));

@@ -767,6 +778,7 @@ static const poafloc::option_t options[] = { {0, 0, 0, 0, "Output mode", 1}, {"output", 'o', "DIR", 0, "Output directory"}, {"force", 'f', 0, 0, "Force write even if file exists"},
{"special", 's', "NAME", 0, "Comma separated files to be rendered to html"},
{0, 0, 0, 0, "General information", 2}, {"base", 'b', "URL", 0, "Absolute destination URL"}, {"resource", 'r', "URL", 0, "URL that houses styles and scripts"},