diff --git a/CHANGELOG.md b/CHANGELOG.md index 582cfcb..4a27953 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +2026.07.23 - Show commit date/time in !gitlog output. (0.40.2) + +- `!gitlog` now shows the commit date and time in `[YYYY-MM-DD HH:MM:SS]` format at the beginning of each commit line (e.g. `[2026-07-22 14:30:15] 184d4c4 Fix whitespace...`). + 2026.07.23 - Fix !zynk key-value timestamps to use localtime. (0.40.1) - Fixed `!zynk key = value` storing UTC timestamps instead of localtime: `db_set()` and the `zynk` table default used `datetime('now')` which returns UTC, causing `!zynk ` to display a timestamp offset by the server's timezone difference. Changed to `datetime('now','localtime')` so timestamps match the system's local time. diff --git a/cmd_gitlog.h b/cmd_gitlog.h index 7264603..3b00e4d 100644 --- a/cmd_gitlog.h +++ b/cmd_gitlog.h @@ -84,7 +84,7 @@ int cmd_gitlog(Session *s, const char *msg, const char *reply_target, const char if (dn >= 0) { dup2(dn, STDERR_FILENO); close(dn); } char cnt[8]; snprintf(cnt, sizeof cnt, "%d", count); - execlp("git", "git", "log", "--format=%H %s", "-n", cnt, (char *)NULL); + execlp("git", "git", "log", "--format=%ci %H %s", "-n", cnt, (char *)NULL); _exit(127); } close(out_pipe[1]); @@ -111,24 +111,35 @@ int cmd_gitlog(Session *s, const char *msg, const char *reply_target, const char char *line = strtok(buf, "\n"); while (line) { while (*line == ' ') line++; - char *sp = strchr(line, ' '); - if (sp) { - *sp = 0; - char *hash = line; - char *msg = sp + 1; - while (*msg == ' ') msg++; - char short_hash[8]; - strncpy(short_hash, hash, 7); - short_hash[7] = 0; - char display[512]; - snprintf(display, sizeof display, "%s %s", short_hash, msg); - collapse_spaces(display); - if (*remote_url) { - char link[4096]; - snprintf(link, sizeof link, "%s - %s/commit/%s", display, remote_url, hash); - irc_msg(s, reply_target, link); + if (strlen(line) > 25 && line[4] == '-' && line[7] == '-' && line[10] == ' ' && + line[13] == ':' && line[16] == ':' && line[19] == ' ') { + char datetime[21]; + memcpy(datetime, line, 19); + datetime[19] = 0; + char *rest = line + 25; + while (*rest == ' ') rest++; + char *sp = strchr(rest, ' '); + if (sp) { + *sp = 0; + char *hash = rest; + char *msg = sp + 1; + while (*msg == ' ') msg++; + char short_hash[8]; + strncpy(short_hash, hash, 7); + short_hash[7] = 0; + char display[512]; + snprintf(display, sizeof display, "[%s] %s %s", datetime, short_hash, msg); + collapse_spaces(display); + if (*remote_url) { + char link[4096]; + snprintf(link, sizeof link, "%s - %s/commit/%s", display, remote_url, hash); + irc_msg(s, reply_target, link); + } else { + irc_msg(s, reply_target, display); + } } else { - irc_msg(s, reply_target, display); + collapse_spaces(rest); + if (*rest) irc_msg(s, reply_target, rest); } } else { collapse_spaces(line);