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 |

commit5763fd26d4dc88a59299f79871da4be7f637a4a4
parent4e37c9157d11068141cfc6fe976e70998de535ae
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateThu, 23 Jan 2025 21:45:36 +0100

Skip everthing if no new commit * Small style nitpicks

Diffstat:
MCMakeLists.txt|+-
Msource/main.cpp|++++++++++++++++++++----------

2 files changed, 21 insertions(+), 11 deletions(-)


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

@@ -4,7 +4,7 @@ include(cmake/prelude.cmake)

project(
startgit
VERSION 0.1.30
VERSION 0.1.31
DESCRIPTION "Static page generator for git repositories"
HOMEPAGE_URL "https://git.dimitrijedobrota.com/stargit.git"
LANGUAGES CXX

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

@@ -90,7 +90,7 @@ void write_header(std::ostream& ost,

bool has_feed = true)
{
write_header(ost,
std::format("{}({}) - {}",
std::format("{} ({}) - {}",
repo.get_name(),
branch.get_name(),
repo.get_description()),

@@ -358,9 +358,11 @@ void write_file_changes(std::ostream& ost, const startgit::diff& diff)

html::a(delta->new_file.path).set("href", link)))
.add(html::td("|"))
.add(html::td()
.add(html::span(" " + std::string(add, '+'))
.add(html::span()
.add(html::text(std::string(add, '+')))
.set("class", "add"))
.add(html::span(" " + std::string(del, '-'))
.add(html::span()
.add(html::text(std::string(del, '-')))
.set("class", "del")));
}

@@ -585,14 +587,16 @@ void write_refs(const std::filesystem::path& base,

write_footer(ofs);
}
void write_commits(const std::filesystem::path& base,
bool write_commits(const std::filesystem::path& base,
const startgit::repository& repo,
const startgit::branch& branch)
{
bool changed = false;
for (const auto& commit : branch.get_commits()) {
const std::string file = base / (commit.get_id() + ".html");
if (!startgit::args.force && std::filesystem::exists(file)) {
continue;
break;
}
std::ofstream ofs(file);

@@ -600,7 +604,10 @@ void write_commits(const std::filesystem::path& base,

write_title(ofs, repo, branch, "../");
write_commit_diff(ofs, commit);
write_footer(ofs);
changed = true;
}
return changed;
}
void write_files(const std::filesystem::path& base,

@@ -805,16 +812,19 @@ int main(int argc, char* argv[])

const std::filesystem::path base_branch = base / branch.get_name();
std::filesystem::create_directory(base_branch);
const std::filesystem::path commit = base_branch / "commit";
std::filesystem::create_directory(commit);
const bool changed = write_commits(commit, repo, branch);
if (!startgit::args.force && !changed) {
continue;
};
write_log(base_branch, repo, branch);
write_file(base_branch, repo, branch);
write_refs(base_branch, repo, branch);
write_readme_licence(base_branch, repo, branch);
const std::filesystem::path commit = base_branch / "commit";
std::filesystem::create_directory(commit);
write_commits(commit, repo, branch);
const std::filesystem::path file = base_branch / "file";
std::filesystem::create_directory(file);