ost << html::table();
}
void write_commit_diff(std::ostream& ost, const git2wrap::commit& commit)
void write_file_changes(std::ostream& ost, const git2wrap::diff& diff)
{
using namespace hemplate; // NOLINT
const auto ptree = commit.get_parentcount() > 0
? commit.get_parent().get_tree()
: git2wrap::tree(nullptr, nullptr);
const auto file_cb =
+[](const git_diff_delta* delta, float /* progress */, void* payload)
{
auto& l_ost = *reinterpret_cast<std::ostream*>(payload); // NOLINT
git2wrap::diff_options opts;
git_diff_init_options(&opts, GIT_DIFF_OPTIONS_VERSION);
opts.flags = GIT_DIFF_DISABLE_PATHSPEC_MATCH | GIT_DIFF_IGNORE_SUBMODULES
| GIT_DIFF_INCLUDE_TYPECHANGE;
static const char* marker = " ADMRC T ";
const auto diff =
git2wrap::diff::tree_to_tree(commit.get_tree(), ptree, &opts);
l_ost << html::tr()
.add(html::td(std::string(1, marker[delta->status])))
.add(html::td(delta->new_file.path))
.add(html::td("|"))
.add(html::td("..."));
return 0;
};
ost << html::b("Diffstat:");
ost << html::table() << html::tbody();
diff.foreach(file_cb, nullptr, nullptr, nullptr, &ost);
ost << html::tbody() << html::table();
/*
ost << html::pre(
std::format("{} files changed, {} insertions(+), {} deletions(-)"));
*/
}
void write_file_diffs(std::ostream& ost, const git2wrap::diff& diff)
{
using namespace hemplate; // NOLINT
const auto file_cb =
+[](const git_diff_delta* delta, float /* progress */, void* payload)