Skip to content

Commit

Permalink
Merge pull request #1183 from apollo13/tag-userusername
Browse files Browse the repository at this point in the history
Added UserUsername (sic) to tag push events.
  • Loading branch information
svanharmelen committed Jul 28, 2021
2 parents ca6bb9b + be60e10 commit 2410c2d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
6 changes: 5 additions & 1 deletion event_parsing_webhook_test.go
Expand Up @@ -381,7 +381,11 @@ func TestParseTagHook(t *testing.T) {
}

if event.UserName != exampleEventUserName {
t.Errorf("Username is %s, want %s", event.UserName, exampleEventUserName)
t.Errorf("Name is %s, want %s", event.UserName, exampleEventUserName)
}

if event.UserUsername != exampleEventUserUsername {
t.Errorf("Username is %s, want %s", event.UserUsername, exampleEventUserUsername)
}

if event.Ref != "refs/tags/v1.0.0" {
Expand Down
25 changes: 13 additions & 12 deletions event_webhook_types.go
Expand Up @@ -855,18 +855,19 @@ type SnippetCommentEvent struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/user/project/integrations/webhooks.html#tag-events
type TagEvent struct {
ObjectKind string `json:"object_kind"`
Before string `json:"before"`
After string `json:"after"`
Ref string `json:"ref"`
CheckoutSHA string `json:"checkout_sha"`
UserID int `json:"user_id"`
UserName string `json:"user_name"`
UserAvatar string `json:"user_avatar"`
UserEmail string `json:"user_email"`
ProjectID int `json:"project_id"`
Message string `json:"message"`
Project struct {
ObjectKind string `json:"object_kind"`
Before string `json:"before"`
After string `json:"after"`
Ref string `json:"ref"`
CheckoutSHA string `json:"checkout_sha"`
UserID int `json:"user_id"`
UserName string `json:"user_name"`
UserUsername string `json:"user_username"`
UserAvatar string `json:"user_avatar"`
UserEmail string `json:"user_email"`
ProjectID int `json:"project_id"`
Message string `json:"message"`
Project struct {
Name string `json:"name"`
Description string `json:"description"`
AvatarURL string `json:"avatar_url"`
Expand Down
5 changes: 4 additions & 1 deletion fixtures_test.go
Expand Up @@ -51,9 +51,12 @@ const (
"locked": false
}`

// exampleEventUserName provides a fixture for a event username.
// exampleEventUserName provides a fixture for a event user's name.
exampleEventUserName = "John Smith"

// exampleEventUserUsername provides a ficture for the event username.
exampleEventUserUsername = "jsmith"

// exampleProjectName provides a fixture for a project name.
exampleProjectName = "example-project"

Expand Down
1 change: 1 addition & 0 deletions testdata/webhooks/tag_push.json
Expand Up @@ -5,6 +5,7 @@
"ref": "refs/tags/v1.0.0",
"checkout_sha": "82b3d5ae55f7080f1e6022629cdb57bfae7cccc7",
"user_id": 1,
"user_username": "jsmith",
"user_name": "John Smith",
"user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80",
"project_id": 1,
Expand Down

0 comments on commit 2410c2d

Please sign in to comment.