diff --git a/.gitignore b/.gitignore index 1972a79..da0083c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ mcchunkie deploy.sh *.core .direnv +result diff --git a/got.go b/got.go index 529cd09..44e1cfd 100644 --- a/got.go +++ b/got.go @@ -43,18 +43,18 @@ type Notification struct { Short bool `json:"short"` Repo string `json:"repo"` ID string `json:"id"` - Author Author `json:"author"` + Author Author `json:"author,omitempty"` Committer Committer `json:"committer"` Date string `json:"date"` ShortMessage string `json:"short_message"` Message string `json:"message"` - Diffstat Diffstat `json:"diffstat"` + Diffstat Diffstat `json:"diffstat,omitempty"` } func (n *Notification) String() string { // op committed got.git f9e653700..f9e653700^1 (main): fix gotd_parse_url() (https://git.gameoftrees.org/gitweb/?p=got.git;a=commitdiff;h=f9e653700) return fmt.Sprintf("%s committed %s %s: %s (%s)", - n.Author.User, + n.Committer.User, n.Repo, n.ID, n.ShortMessage, diff --git a/got_test.sh b/got_test.sh new file mode 100755 index 0000000..eb96432 --- /dev/null +++ b/got_test.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +echo "line one is here" > /tmp/test +echo "line two is here" >> /tmp/test +echo "line is here" >> /tmp/test + +curl --basic --user got:butters --data-urlencode file@/tmp/test -o - "http://localhost:8043/_got" +curl -X POST -H "Content-Type: application/json" --data @test_body.json --basic --user got:butters -o - "http://localhost:8043/_got/v2" diff --git a/live_got_test.sh b/live_got_test.sh new file mode 100755 index 0000000..e226a0e --- /dev/null +++ b/live_got_test.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +PW="$(op item get got-test --field password)" + +echo "test one two three" > /tmp/test + +curl --basic --user got:${PW} --data-urlencode file@/tmp/test -o - "https://suah.dev/_got" +curl -X POST -H "Content-Type: application/json" --data @test_body.json --basic --user got:${PW} -o - "https://suah.dev/_got/v2" + diff --git a/test_body.json b/test_body.json new file mode 100644 index 0000000..1937a22 --- /dev/null +++ b/test_body.json @@ -0,0 +1,89 @@ +{ + "notifications": [ + { + "type": "commit", + "short": false, + "repo": "test-repo", + "id": "34d7c970d4bd3a5832ecded86f2c28e83dbba2ba", + "author": { + "full": "Flan Hacker ", + "name": "Flan Hacker", + "mail": "flan@openbsd.org", + "user": "flan" + }, + "committer": { + "full": "Flan Hacker ", + "name": "Flan Hacker", + "mail": "flan@openbsd.org", + "user": "flan" + }, + "date": "Thu Apr 18 16:47:40 2024 UTC", + "short_message": "make changes", + "message": "make changes\n", + "diffstat": { + "files": [ + { + "action": "modified", + "file": "alpha", + "added": 1, + "removed": 1 + } + ], + "total": { + "added": 1, + "removed": 1 + } + } + }, + { + "type": "commit", + "short": false, + "repo": "repo-test", + "id": "a4d7c970d4bd3a5832ecded86f2c28e83dbba2ba", + "author": { + "full": "Flan Slacker ", + "name": "Flan Slacker", + "mail": "flans@openbsd.org", + "user": "flans" + }, + "committer": { + "full": "Flan Slacker ", + "name": "Flan Slacker", + "mail": "flans@openbsd.org", + "user": "flans" + }, + "date": "Thu Apr 18 16:48:40 2024 UTC", + "short_message": "make more changes", + "message": "make more changes\n", + "diffstat": { + "files": [ + { + "action": "modified", + "file": "alpha", + "added": 3, + "removed": 8 + } + ], + "total": { + "added": 1, + "removed": 9 + } + } + }, + { + "type": "commit", + "short": false, + "repo": "repo-test", + "id": "f4d7c970d4bd3a5832ecded86f2c28e83dbba2ba", + "committer": { + "full": "Flan Slacker ", + "name": "Flan Slacker", + "mail": "flans@openbsd.org", + "user": "flans" + }, + "date": "Thu Apr 19 16:48:40 2024 UTC", + "short_message": "revert changes", + "message": "revert all the previous changes\n" + } + ] +}