commit 936239010f884c916c0f8680490fea91813b5334 from: Omar Polo date: Thu Mar 28 15:20:42 2024 UTC got-notify-http: add a type:commit field in the json will help to differentiate these notification objects from the others. commit - a4656c38219b986dc7919a9c5c36195b9dd0acee commit + 936239010f884c916c0f8680490fea91813b5334 blob - 21b945c5399e95211b7acd18feab5b68a8bbe96d blob + 7bd3f39814f8f94fc9ed5420279174e53e0d92a1 --- gotd/libexec/got-notify-http/got-notify-http.c +++ gotd/libexec/got-notify-http/got-notify-http.c @@ -212,7 +212,7 @@ jsonify_commit_short(FILE *fp, char *line) message = t; - fprintf(fp, "{\"short\":true,"); + fprintf(fp, "{\"type\":\"commit\",\"short\":true,"); json_field(fp, "id", id, 1); json_author(fp, "committer", author, 1); json_field(fp, "date", date, 1); @@ -247,7 +247,7 @@ jsonify_commit(FILE *fp, char **line, ssize_t *linesiz if (strncmp(l, "commit ", 7) != 0) errx(1, "%s: unexpected line: %s", __func__, l); l += 7; - fprintf(fp, "{\"short\":false,"); + fprintf(fp, "{\"type\":\"commit\",\"short\":false,"); json_field(fp, "id", l, 1); while (!done) { blob - 51fc31fca5b661529114910cf87eed04f5611301 blob + a83c9622d1b9c26800dad3d240170b2a0e2798c6 --- regress/gotd/http_notification.sh +++ regress/gotd/http_notification.sh @@ -60,6 +60,7 @@ test_file_changed() { ed -s "$testroot/stdout.expected" <<-EOF a {"notifications":[{ + "type":"commit", "short":false, "id":"$commit_id", "author":{ @@ -141,6 +142,7 @@ test_bad_utf8() { ed -s "$testroot/stdout.expected" <<-EOF a {"notifications":[{ + "type":"commit", "short":false, "id":"$commit_id", "author":{ @@ -230,6 +232,7 @@ test_many_commits_not_summarized() { cat <<-EOF { + "type":"commit", "short":false, "id":"$commit_id", "author":{ @@ -323,6 +326,7 @@ test_many_commits_summarized() { cat <<-EOF { + "type":"commit", "short":true, "id":"$commit_id", "committer":{