commit c29409f9fb2acedc978ae8232c2ba5f958c83445 from: Stefan Sperling via: Thomas Adam date: Mon Apr 29 12:23:45 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 - bdf7ef6f884f541cbc9915752a2667570b3572c5 commit + c29409f9fb2acedc978ae8232c2ba5f958c83445 blob - 7fae44225c920ee600411e33b08a85e7f1f7d186 blob + 7cbf807ff0f1d429e06cb60068afd9f1e044f05d --- gotd/libexec/got-notify-http/got-notify-http.c +++ gotd/libexec/got-notify-http/got-notify-http.c @@ -222,8 +222,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); @@ -256,8 +255,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); @@ -298,8 +296,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) { @@ -590,8 +587,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) { @@ -896,7 +892,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";