From f1ee5e82f41ab5ee0d1e3aa81779c2bbba8dc2ab Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 1 Aug 2024 18:30:29 -0400 Subject: [PATCH] The watchgit works but I don't think I really need libgit2 at all if I can just process the .gitignore correctly. --- .gitignore | 1 + regtest.cpp | 5 +++-- watchgit.cpp | 11 +++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index e2743a2..39151ec 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ builddir subprojects *.csv *.exe +*.dll diff --git a/regtest.cpp b/regtest.cpp index 52dac98..6480239 100644 --- a/regtest.cpp +++ b/regtest.cpp @@ -7,12 +7,13 @@ using namespace std; int main(int argc, char *argv[]) { smatch matches; - regex to_test(argv[1]); - string line(argv[2]); if(argc != 3) { println("USAGE: regtest "); } else { + regex to_test(argv[1]); + string line(argv[2]); + if(regex_match(line, matches, to_test)) { println("MATCHED: "); diff --git a/watchgit.cpp b/watchgit.cpp index 1916240..5debc5c 100644 --- a/watchgit.cpp +++ b/watchgit.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -114,8 +115,7 @@ void run_build(const char* command) { char buffer[BUF_MAX]; // BUF_MAX is a define already? ofstream stats_out; stats_out.open("stats.csv", ios::out | ios::app); - auto t = time(nullptr); - auto tm = *std::gmtime(&t); + std::time_t tstamp = std::time(nullptr); dbc::check(stats_out.good(), "Error opening stats.csv file."); dbc::pre("simple test", [&]() { return stats_out.good(); }); @@ -136,13 +136,12 @@ void run_build(const char* command) { string type = err[4].str(); string message = err[5].str(); - stats_out << put_time(&tm, "%FT%TZ"); - string result = format(",{},{},{},{},{}\n", file_name, lnumber, col, type, message); + string result = format("{:%FT%T},{},{},{},{},{}\n", + fmt::localtime(tstamp), file_name, + lnumber, col, type, message); stats_out << result; cout << "MATCHED: " << quoted(result); - } else { - //println("NOT MATCHED! {}", line); } }