commit 9d42388a1a146c8563b1eae304f084a5881c09b9 from: Stefan Sperling date: Mon Apr 29 11:57:20 2024 UTC require -u option when invoking got-notify-http The authenticated username is always available so it makes little sense to treat it as an optional parameter. Suggested by op@ commit - d36998aec867c8134466eccfe048dc8671eecca5 commit + 9d42388a1a146c8563b1eae304f084a5881c09b9 blob - 110aa3179a27bd4af209fd577262ccccdd94f82b blob + 34cebb840cd2748f8de2cf177553261cab74e768 --- gotd/libexec/got-notify-http/got-notify-http.c +++ gotd/libexec/got-notify-http/got-notify-http.c @@ -220,8 +220,7 @@ jsonify_branch_rm(FILE *fp, char *line, const char *re fputc('{', fp); json_field(fp, "type", "branch-deleted", 1); json_field(fp, "repo", repo, 1); - if (user) - json_field(fp, "auth_user", user, 1); + json_field(fp, "auth_user", user, 1); json_field(fp, "ref", ref, 1); json_field(fp, "id", id, 0); fputc('}', fp); @@ -254,8 +253,7 @@ jsonify_commit_short(FILE *fp, char *line, const char fprintf(fp, "{\"type\":\"commit\",\"short\":true,"); json_field(fp, "repo", repo, 1); - if (user) - json_field(fp, "auth_user", user, 1); + json_field(fp, "auth_user", user, 1); json_field(fp, "id", id, 1); json_author(fp, "committer", author, 1); json_date(fp, "date", date, 1); @@ -296,8 +294,7 @@ jsonify_commit(FILE *fp, const char *repo, const char fprintf(fp, "{\"type\":\"commit\",\"short\":false,"); json_field(fp, "repo", repo, 1); - if (user) - json_field(fp, "auth_user", user, 1); + json_field(fp, "auth_user", user, 1); json_field(fp, "id", l, 1); while (!done) { @@ -588,8 +585,7 @@ jsonify_tag(FILE *fp, const char *repo, const char *us fputc('{', fp); json_field(fp, "type", "tag", 1); json_field(fp, "repo", repo, 1); - if (user) - json_field(fp, "auth_user", user, 1); + json_field(fp, "auth_user", user, 1); json_field(fp, "tag", l, 1); while (!done) { @@ -894,7 +890,7 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (host == NULL || repo == NULL || argc != 1) + if (host == NULL || repo == NULL || gotd_auth_user == NULL || argc != 1) usage(); if (tls && port == NULL) port = "443";