commit - 813645df7b21d54ae779e80fc6e7ad9c913b67d6
commit + c1003102a22a77d068a14f9ffa7877f67c28e95d
blob - a496fde3da3e6887293b606aae85015172b8a382
blob + 6b1e63e34c2c42b7aeff0c238e2a303c5efa7c2a
--- gotd/gotd.conf.5
+++ gotd/gotd.conf.5
Boolean, indicates whether the object has all the fields set.
When several commits are batched in a single send operation, not all of
the fields are available for each commit object.
+.It Dv repo
+The repository name as string.
.It Dv id
The commit ID as string, may be abbreviated.
.It Dv committer
The branch deleted notifications has the following fields, all guaranteed
to be set:
.Bl -tag -compact -width Ds
+.It Dv repo
+The repository name as string.
.It Dv ref
The removed branch reference.
.It Dv id
.It Dv tag
The tag notification has the following fields, all guaranteed to be set:
.Bl -tag -width Ds
+.It repo
+The repository name as string.
.It tag
The tag reference.
.It tagger
blob - 2b04222ed9896664bd3fd8b05fc126ae38feb27a
blob + 9c8a90e392c27e03eb1dd32a88414aa62a355012
--- gotd/libexec/got-notify-http/got-notify-http.c
+++ gotd/libexec/got-notify-http/got-notify-http.c
__dead static void
usage(void)
{
- fprintf(stderr, "usage: %s [-c] -h host -p port path\n",
+ fprintf(stderr, "usage: %s [-c] -r repo -h host -p port path\n",
getprogname());
exit(1);
}
}
static int
-jsonify_branch_rm(FILE *fp, char *line)
+jsonify_branch_rm(FILE *fp, char *line, const char *repo)
{
char *ref, *id;
fputc('{', fp);
json_field(fp, "type", "branch-deleted", 1);
+ json_field(fp, "repo", repo, 1);
json_field(fp, "ref", ref, 1);
json_field(fp, "id", id, 0);
fputc('}', fp);
}
static int
-jsonify_commit_short(FILE *fp, char *line)
+jsonify_commit_short(FILE *fp, char *line, const char *repo)
{
char *t, *date, *id, *author, *message;
message = t;
fprintf(fp, "{\"type\":\"commit\",\"short\":true,");
+ json_field(fp, "repo", repo, 1);
json_field(fp, "id", id, 1);
json_author(fp, "committer", author, 1);
json_field(fp, "date", date, 1);
}
static int
-jsonify_commit(FILE *fp, char **line, ssize_t *linesize)
+jsonify_commit(FILE *fp, const char *repo, char **line, ssize_t *linesize)
{
const char *errstr;
char *author = NULL;
l += 7;
fprintf(fp, "{\"type\":\"commit\",\"short\":false,");
+ json_field(fp, "repo", repo, 1);
json_field(fp, "id", l, 1);
while (!done) {
}
static int
-jsonify_tag(FILE *fp, char **line, ssize_t *linesize)
+jsonify_tag(FILE *fp, const char *repo, char **line, ssize_t *linesize)
{
const char *errstr;
char *l;
fputc('{', fp);
json_field(fp, "type", "tag", 1);
+ json_field(fp, "repo", repo, 1);
json_field(fp, "tag", l, 1);
while (!done) {
}
static int
-jsonify(FILE *fp)
+jsonify(FILE *fp, const char *repo)
{
char *line = NULL;
size_t linesize = 0;
needcomma = 1;
if (strncmp(line, "Removed refs/heads/", 19) == 0) {
- if (jsonify_branch_rm(fp, line) == -1)
+ if (jsonify_branch_rm(fp, line, repo) == -1)
err(1, "jsonify_branch_rm");
continue;
}
if (strncmp(line, "commit ", 7) == 0) {
- if (jsonify_commit(fp, &line, &linesize) == -1)
+ if (jsonify_commit(fp, repo, &line, &linesize) == -1)
err(1, "jsonify_commit");
continue;
}
if (*line >= '0' && *line <= '9') {
- if (jsonify_commit_short(fp, line) == -1)
+ if (jsonify_commit_short(fp, line, repo) == -1)
err(1, "jsonify_commit_short");
continue;
}
if (strncmp(line, "tag ", 4) == 0) {
- if (jsonify_tag(fp, &line, &linesize) == -1)
+ if (jsonify_tag(fp, repo, &line, &linesize) == -1)
err(1, "jsonify_tag");
continue;
}
const char *password;
const char *timeoutstr;
const char *errstr;
+ const char *repo = NULL;
const char *host = NULL, *port = NULL, *path = NULL;
char *auth, *line, *spc;
size_t len;
err(1, "pledge");
#endif
- while ((ch = getopt(argc, argv, "ch:p:")) != -1) {
+ while ((ch = getopt(argc, argv, "ch:p:r:")) != -1) {
switch (ch) {
case 'c':
tls = 1;
case 'p':
port = optarg;
break;
+ case 'r':
+ repo = optarg;
+ break;
default:
usage();
}
argc -= optind;
argv += optind;
- if (host == NULL || argc != 1)
+ if (host == NULL || repo == NULL || argc != 1)
usage();
if (tls && port == NULL)
port = "443";
if (tmpfp == NULL)
err(1, "opentemp");
- jsonify(tmpfp);
+ jsonify(tmpfp, repo);
paylen = ftello(tmpfp);
if (paylen == -1)
blob - 130421d61e42a690b8ee37a09bbf38b3bc2da092
blob + 682368c09afd8f26371f3c0eb5b63f700ac39026
--- gotd/notify.c
+++ gotd/notify.c
}
static void
-notify_http(struct gotd_notification_target *target, int fd)
+notify_http(struct gotd_notification_target *target, const char *repo, int fd)
{
- const char *argv[8];
+ const char *argv[10];
int argc = 0;
argv[argc++] = GOTD_PATH_PROG_NOTIFY_HTTP;
if (target->conf.http.tls)
argv[argc++] = "-c";
+ argv[argc++] = "-r";
+ argv[argc++] = repo;
argv[argc++] = "-h";
argv[argc++] = target->conf.http.hostname;
argv[argc++] = "-p";
notify_email(target, inotify.subject_line, fd);
break;
case GOTD_NOTIFICATION_VIA_HTTP:
- notify_http(target, fd);
+ notify_http(target, repo->name, fd);
break;
}
}
blob - 4e4fcae3bf98da908b2d453065c14d86ec1cd55b
blob + 38661743a189d324f50db59d65ebfb278ed84eff
--- regress/gotd/http_notification.sh
+++ regress/gotd/http_notification.sh
{"notifications":[{
"type":"commit",
"short":false,
+ "repo":"test-repo",
"id":"$commit_id",
"author":{
"full":"$GOT_AUTHOR",
{"notifications":[{
"type":"commit",
"short":false,
+ "repo":"test-repo",
"id":"$commit_id",
"author":{
"full":"$GOT_AUTHOR",
{
"type":"commit",
"short":false,
+ "repo":"test-repo",
"id":"$commit_id",
"author":{
"full":"$GOT_AUTHOR",
{
"type":"commit",
"short":true,
+ "repo":"test-repo",
"id":"$commit_id",
"committer":{
"user":"$GOT_AUTHOR_8"
{
"type":"commit",
"short":false,
+ "repo":"test-repo",
"id":"$commit_id",
"author":{
"full":"$GOT_AUTHOR",
a
{"notifications":[{
"type":"branch-deleted",
+ "repo":"test-repo",
"ref":"refs/heads/newbranch",
"id":"$commit_id"
}]}
a
{"notifications":[{
"type":"tag",
+ "repo":"test-repo",
"tag":"refs/tags/1.0",
"tagger":{
"full":"$GOT_AUTHOR",
a
{"notifications":[{
"type":"tag",
+ "repo":"test-repo",
"tag":"refs/tags/1.0",
"tagger":{
"full":"$GOT_AUTHOR",