diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d596f6..ecfb8be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Added `!gitlog [count]` command: displays recent git commits of the zynk project using `git log --oneline`. Defaults to 5 commits (`GITLOG_COUNT`), accepts 1–20 as count. Each commit is sent as a separate IRC message. - Updated `!help` to list `!gitlog`. - Updated README.md with `!gitlog` documentation and `git` as a requirement. +- Added detailed doc comment to `cmd_gitlog()` matching the style of all other function documentation in zynk.c. - Version bumped to 0.36.0. 2026.07.20 – Remove timezone abbreviation from !time response. diff --git a/zynk.c b/zynk.c index a3e849c..c14de08 100644 --- a/zynk.c +++ b/zynk.c @@ -53,6 +53,7 @@ enum { RATE_LIMIT_MAX = 8, MAX_HISTORY = 100, GITLOG_COUNT = 5, + GITLOG_MAX = 20, }; /* ---- IRC session ---- */ @@ -3009,6 +3010,27 @@ static int cmd_tell(Session *s, const char *msg, const char *reply_target, const return 1; } +/* + * cmd_gitlog - Handle the "!gitlog [count]" command. + * + * Displays recent git commits of the zynk project by forking a child + * process that runs "git log --oneline -n ". Each commit line + * is sent as a separate IRC PRIVMSG to the reply target. The commit + * count defaults to GITLOG_COUNT (5) when no argument is provided, + * and is clamped to GITLOG_MAX (20) if the user requests more. + * Rate-limited per-nick. If git is not installed or the working + * directory is not a git repository, an appropriate error message is + * sent. If no commits exist (e.g. fresh repo), reports that no commits + * were found. + * + * Parameters: + * s - The IRC session. + * msg - The raw IRC message text. + * reply_target - Channel or nick to send the response to. + * src_nick - The IRC nick of the user who issued the command. + * + * Returns: 1 if the command was matched, 0 otherwise. + */ static int cmd_gitlog(Session *s, const char *msg, const char *reply_target, const char *src_nick) { if (strncmp(msg, "!gitlog", 7) != 0) return 0; if (msg[7] != ' ' && msg[7] != '\0') return 0; @@ -3019,7 +3041,7 @@ static int cmd_gitlog(Session *s, const char *msg, const char *reply_target, con if (*rest) { count = atoi(rest); if (count <= 0) count = GITLOG_COUNT; - if (count > 20) count = 20; + if (count > GITLOG_MAX) count = GITLOG_MAX; } int out_pipe[2]; if (pipe(out_pipe) < 0) { irc_msg(s, reply_target, "gitlog: internal error"); return 1; }