From 9d02048dc06a3809658b9930ac5f994b66a06656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Mon, 1 Dec 2014 14:09:08 +0100 Subject: [PATCH] qlop -s: support git sync messages --- qlop.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/qlop.c b/qlop.c index d5e2226..2080fdd 100644 --- a/qlop.c +++ b/qlop.c @@ -319,13 +319,23 @@ show_sync_history(const char *logfile) buf = NULL; while (getline(&buf, &buflen, fp) != -1) { - if (strlen(buf) < 35) + /* Possibilities: + * 1417415175: === Sync completed with rsync://... + * 1417299771: >>> Git pull successful: /usr/portage + * 1417438324: >>> Git clone successful + * ^ ^ ^ + * 123456789012345678901234567890123456 + */ + if (strlen(buf) < 36) continue; - if (strncmp(buf+12, "=== Sync completed with", 23) != 0) + if (strncmp(buf+12, "=== Sync completed with", 23) != 0 + && strncmp(buf+12, ">>> Git pull successful:", 24) != 0 + && strncmp(buf+12, ">>> Git clone successful", 24) != 0) continue; if ((p = strchr(buf, '\n')) != NULL) *p = 0; + /* timestamp */ if ((p = strchr(buf, ':')) == NULL) continue; *p = 0; @@ -333,11 +343,23 @@ show_sync_history(const char *logfile) t = (time_t)atol(buf); - if ((p = strstr(q, "with")) == NULL) - continue; - q = p + 5; - - printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM); + if ((p = strstr(q, "with")) != NULL) + { + /* 'Sync completed with' variant */ + q = p + 5; + printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM); + } + else if ((p = strchr(q, ':')) != NULL) + { + /* 'Git pull successful:' variant */ + q = p + 2; + printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM); + } + else + { + /* '>>> Git clone successful' variant */ + printf("%s >>> %s[initial clone]%s\n", chop_ctime(t), GREEN, NORM); + } } free(buf); -- 2.1.3