got: omit empty for author, difstat. use committer for String()

This commit is contained in:
Aaron Bieber 2024-04-22 09:01:26 -06:00
parent 3dab4d2d75
commit 8d6703594b
No known key found for this signature in database
5 changed files with 110 additions and 3 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ mcchunkie
deploy.sh
*.core
.direnv
result

6
got.go
View File

@ -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,

8
got_test.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
echo "line one is here" > /tmp/test
echo "line two is here" >> /tmp/test
echo "line <two> 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"

9
live_got_test.sh Executable file
View File

@ -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"

89
test_body.json Normal file
View File

@ -0,0 +1,89 @@
{
"notifications": [
{
"type": "commit",
"short": false,
"repo": "test-repo",
"id": "34d7c970d4bd3a5832ecded86f2c28e83dbba2ba",
"author": {
"full": "Flan Hacker <flan@openbsd.org>",
"name": "Flan Hacker",
"mail": "flan@openbsd.org",
"user": "flan"
},
"committer": {
"full": "Flan Hacker <flan@openbsd.org>",
"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 <flans@openbsd.org>",
"name": "Flan Slacker",
"mail": "flans@openbsd.org",
"user": "flans"
},
"committer": {
"full": "Flan Slacker <flan@openbsd.org>",
"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 <flan@openbsd.org>",
"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"
}
]
}