diff --git a/gitea/gitea.go b/gitea/gitea.go new file mode 100644 index 0000000..8c80357 --- /dev/null +++ b/gitea/gitea.go @@ -0,0 +1,179 @@ +package gitea + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "io" + "io/ioutil" + "net/http" +) + +// parse errors +var ( + ErrEventNotSpecifiedToParse = errors.New("no Event specified to parse") + ErrInvalidHTTPMethod = errors.New("invalid HTTP Method") + ErrMissingGiteaEventHeader = errors.New("missing X-Gitea-Event Header") + ErrMissingGiteaSignatureHeader = errors.New("missing X-Gitea-Signature Header") + ErrEventNotFound = errors.New("event not defined to be parsed") + ErrParsingPayload = errors.New("error parsing payload") + ErrHMACVerificationFailed = errors.New("HMAC verification failed") +) + +// Gitea hook types +// https://github.com/go-gitea/gitea/blob/bf7b083cfe47cc922090ce7922b89f7a5030a44d/models/webhook/hooktask.go#L31 +const ( + CreateEvent Event = "create" + DeleteEvent Event = "delete" + ForkEvent Event = "fork" + IssuesEvent Event = "issues" + IssueAssignEvent Event = "issue_assign" + IssueLabelEvent Event = "issue_label" + IssueMilestoneEvent Event = "issue_milestone" + IssueCommentEvent Event = "issue_comment" + PushEvent Event = "push" + PullRequestEvent Event = "pull_request" + PullRequestAssignEvent Event = "pull_request_assign" + PullRequestLabelEvent Event = "pull_request_label" + PullRequestMilestoneEvent Event = "pull_request_milestone" + PullRequestCommentEvent Event = "pull_request_comment" + PullRequestReviewEvent Event = "pull_request_review" + PullRequestSyncEvent Event = "pull_request_sync" + RepositoryEvent Event = "repository" + ReleaseEvent Event = "release" +) + +// Option is a configuration option for the webhook +type Option func(*Webhook) error + +// Options is a namespace var for configuration options +var Options = WebhookOptions{} + +// WebhookOptions is a namespace for configuration option methods +type WebhookOptions struct{} + +// Secret registers the GitLab secret +func (WebhookOptions) Secret(secret string) Option { + return func(hook *Webhook) error { + hook.secret = secret + return nil + } +} + +// Webhook instance contains all methods needed to process events +type Webhook struct { + secret string +} + +// Event defines a GitLab hook event type by the X-Gitlab-Event Header +type Event string + +// New creates and returns a WebHook instance denoted by the Provider type +func New(options ...Option) (*Webhook, error) { + hook := new(Webhook) + for _, opt := range options { + if err := opt(hook); err != nil { + return nil, errors.New("Error applying Option") + } + } + return hook, nil +} + +// Parse verifies and parses the events specified and returns the payload object or an error +func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) { + defer func() { + _, _ = io.Copy(ioutil.Discard, r.Body) + _ = r.Body.Close() + }() + + if len(events) == 0 { + return nil, ErrEventNotSpecifiedToParse + } + if r.Method != http.MethodPost { + return nil, ErrInvalidHTTPMethod + } + + event := r.Header.Get("X-Gitea-Event") + if len(event) == 0 { + return nil, ErrMissingGiteaEventHeader + } + + giteaEvent := Event(event) + + var found bool + for _, evt := range events { + if evt == giteaEvent { + found = true + break + } + } + // event not defined to be parsed + if !found { + return nil, ErrEventNotFound + } + + payload, err := ioutil.ReadAll(r.Body) + if err != nil || len(payload) == 0 { + return nil, ErrParsingPayload + } + + // If we have a Secret set, we should check the MAC + if len(hook.secret) > 0 { + signature := r.Header.Get("X-Gitea-Signature") + if len(signature) == 0 { + return nil, ErrMissingGiteaSignatureHeader + } + sig256 := hmac.New(sha256.New, []byte(hook.secret)) + _, _ = io.Writer(sig256).Write([]byte(payload)) + expectedMAC := hex.EncodeToString(sig256.Sum(nil)) + + if !hmac.Equal([]byte(signature), []byte(expectedMAC)) { + return nil, ErrHMACVerificationFailed + } + } + + // https://github.com/go-gitea/gitea/blob/33fca2b537d36cf998dd27425b2bb8ed5b0965f3/services/webhook/payloader.go#L27 + switch giteaEvent { + case CreateEvent: + var pl CreatePayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + case DeleteEvent: + var pl DeletePayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + case ForkEvent: + var pl ForkPayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + case PushEvent: + var pl PushPayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + case IssuesEvent, IssueAssignEvent, IssueLabelEvent, IssueMilestoneEvent: + var pl IssuePayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + case IssueCommentEvent, PullRequestCommentEvent: + var pl IssueCommentPayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + case PullRequestEvent, PullRequestAssignEvent, PullRequestLabelEvent, PullRequestMilestoneEvent, PullRequestReviewEvent, PullRequestSyncEvent: + var pl PullRequestPayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + case RepositoryEvent: + var pl RepositoryPayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + case ReleaseEvent: + var pl ReleasePayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + default: + return nil, fmt.Errorf("unknown event %s", giteaEvent) + } +} diff --git a/gitea/gitea_test.go b/gitea/gitea_test.go new file mode 100644 index 0000000..d1ce586 --- /dev/null +++ b/gitea/gitea_test.go @@ -0,0 +1,335 @@ +package gitea + +import ( + "bytes" + "log" + "net/http" + "net/http/httptest" + "os" + "reflect" + "testing" + + "io" + + "github.com/stretchr/testify/require" +) + +// NOTES: +// - Run "go test" to run tests +// - Run "gocov test | gocov report" to report on test converage by file +// - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called +// +// or +// +// -- may be a good idea to change to output path to somewherelike /tmp +// go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html +// + +const ( + path = "/webhooks" +) + +var hook *Webhook + +func TestMain(m *testing.M) { + + // setup + var err error + hook, err = New(Options.Secret("IsWishesWereHorsesWedAllBeEatingSteak!")) + if err != nil { + log.Fatal(err) + } + os.Exit(m.Run()) + // teardown +} + +func newServer(handler http.HandlerFunc) *httptest.Server { + mux := http.NewServeMux() + mux.HandleFunc(path, handler) + return httptest.NewServer(mux) +} + +func TestBadRequests(t *testing.T) { + assert := require.New(t) + tests := []struct { + name string + event Event + payload io.Reader + headers http.Header + }{ + { + name: "BadNoEventHeader", + event: PushEvent, + payload: bytes.NewBuffer([]byte("{}")), + headers: http.Header{}, + }, + { + name: "UnsubscribedEvent", + event: PushEvent, + payload: bytes.NewBuffer([]byte("{}")), + headers: http.Header{ + "X-Gitea-Event": []string{"noneexistant_event"}, + }, + }, + { + name: "BadBody", + event: PushEvent, + payload: bytes.NewBuffer([]byte("")), + headers: http.Header{ + "X-Gitea-Event": []string{"push"}, + }, + }, + { + name: "BadSignatureLength", + event: PushEvent, + payload: bytes.NewBuffer([]byte("{}")), + headers: http.Header{ + "X-Gitea-Event": []string{"push"}, + "X-Gitea-Signature": []string{""}, + }, + }, + { + name: "BadSignatureMatch", + event: PushEvent, + payload: bytes.NewBuffer([]byte("{}")), + headers: http.Header{ + "X-Gitea-Event": []string{"push"}, + "X-Gitea-Signature": []string{"111"}, + }, + }, + } + + for _, tt := range tests { + tc := tt + client := &http.Client{} + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + var parseError error + server := newServer(func(w http.ResponseWriter, r *http.Request) { + _, parseError = hook.Parse(r, tc.event) + }) + defer server.Close() + req, err := http.NewRequest(http.MethodPost, server.URL+path, tc.payload) + assert.NoError(err) + req.Header = tc.headers + req.Header.Set("Content-Type", "application/json") + + resp, err := client.Do(req) + assert.NoError(err) + assert.Equal(http.StatusOK, resp.StatusCode) + assert.Error(parseError) + }) + } +} + +func TestWebhooks(t *testing.T) { + assert := require.New(t) + tests := []struct { + name string + event Event + typ interface{} + filename string + headers http.Header + }{ + { + name: "CreateEvent", + event: CreateEvent, + typ: CreatePayload{}, + filename: "../testdata/gitea/create-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"create"}, + "X-Gitea-Signature": []string{"6f250ac7a090096574758e31bd31770eab63dfd0459404f0c18431f1c6b9024a"}, + }, + }, + { + name: "DeleteEvent", + event: DeleteEvent, + typ: DeletePayload{}, + filename: "../testdata/gitea/delete-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"delete"}, + "X-Gitea-Signature": []string{"84307b509e663cd897bc719b2a564e64fa4af8716fda389488f18369139e0fdd"}, + }, + }, + { + name: "ForkEvent", + event: ForkEvent, + typ: ForkPayload{}, + filename: "../testdata/gitea/fork-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"fork"}, + "X-Gitea-Signature": []string{"b7750f34adeaf333ac83a1fadcda4cbac097c8587e8dda297c3e7f059012215f"}, + }, + }, + { + name: "IssuesEvent", + event: IssuesEvent, + typ: IssuePayload{}, + filename: "../testdata/gitea/issues-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"issues"}, + "X-Gitea-Signature": []string{"98c44fd0ae42ca4208eac6f81e59b436837740abc8693bf828366b32d33b1cbc"}, + }, + }, + { + name: "IssueAssignEvent", + event: IssueAssignEvent, + typ: IssuePayload{}, + filename: "../testdata/gitea/issue-assign-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"issue_assign"}, + "X-Gitea-Signature": []string{"7d2adaf2fb3dc3769294c737ff48da003b7c3660b4f917b85c2c25dabd34a13c"}, + }, + }, + { + name: "IssueLabelEvent", + event: IssueLabelEvent, + typ: IssuePayload{}, + filename: "../testdata/gitea/issue-label-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"issue_label"}, + "X-Gitea-Signature": []string{"3611415860ed5904c87dd589a7c5fa7e87d2a72b0b2a92ea149ba9691ba8c785"}, + }, + }, + { + name: "IssueMilestoneEvent", + event: IssueMilestoneEvent, + typ: IssuePayload{}, + filename: "../testdata/gitea/issue-milestone-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"issue_milestone"}, + "X-Gitea-Signature": []string{"4b782b02035ca264c8e7782b8f2eb9d64e4a61344a1bc3a08fa85d7eed1e77b5"}, + }, + }, + { + name: "IssueCommentEvent", + event: IssueCommentEvent, + typ: IssueCommentPayload{}, + filename: "../testdata/gitea/issue-comment-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"issue_comment"}, + "X-Gitea-Signature": []string{"690180a8c853460cba88f9b09911a531d449e9f63ed6b1ff0a0def3b972ca744"}, + }, + }, + { + name: "PushEvent", + event: PushEvent, + typ: PushPayload{}, + filename: "../testdata/gitea/push-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"push"}, + "X-Gitea-Signature": []string{"60fe446c74fa0cb9474f98cc557db79e10c7aaf22cf324ad65239600b9e4d915"}, + }, + }, + { + name: "PullRequestEvent", + event: PullRequestEvent, + typ: PullRequestPayload{}, + filename: "../testdata/gitea/pull-request-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"pull_request"}, + "X-Gitea-Signature": []string{"65c18a212efc7bde0f336acaec87f596fe20e80b2a0e7e51a790dd38393ff771"}, + }, + }, + { + name: "PullRequestAssignEvent", + event: PullRequestAssignEvent, + typ: PullRequestPayload{}, + filename: "../testdata/gitea/pull-request-assign-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"pull_request_assign"}, + "X-Gitea-Signature": []string{"6e96f0515898d427d87fc022cef60e4a02695739e8eae05f8cccd79b2ce4809a"}, + }, + }, + { + name: "PullRequestLabelEvent", + event: PullRequestLabelEvent, + typ: PullRequestPayload{}, + filename: "../testdata/gitea/pull-request-label-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"pull_request_label"}, + "X-Gitea-Signature": []string{"c52fa035b8d9ac4d94449349b16bac5892bc59faa72be19ff39f33b6bc24315a"}, + }, + }, + { + name: "PullRequestMilestoneEvent", + event: PullRequestMilestoneEvent, + typ: PullRequestPayload{}, + filename: "../testdata/gitea/pull-request-milestone-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"pull_request_milestone"}, + "X-Gitea-Signature": []string{"38b2cf88e15b15795371517cb4121a92c7db1116f83eba57c13c192a7e0730dc"}, + }, + }, + { + name: "PullRequestCommentEvent", + event: PullRequestCommentEvent, + typ: IssueCommentPayload{}, + filename: "../testdata/gitea/pull-request-comment-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"pull_request_comment"}, + "X-Gitea-Signature": []string{"8b38bf221adbaef2ce01cfa810c6d9cb977414fec306895973aea61e10e8d5a8"}, + }, + }, + { + name: "PullRequestReviewEvent", + event: PullRequestReviewEvent, + typ: PullRequestPayload{}, + filename: "../testdata/gitea/pull-request-review-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"pull_request_review"}, + "X-Gitea-Signature": []string{"5d5c315cc199807a23da81b788dcf7874299a223ba81fc77d76ab248fdab4d1c"}, + }, + }, + { + name: "RepositoryEvent", + event: RepositoryEvent, + typ: RepositoryPayload{}, + filename: "../testdata/gitea/repository-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"repository"}, + "X-Gitea-Signature": []string{"52ca39cfb873254a9cbbda10f8a878f9df16216da6ae92267fc81352ac685d97"}, + }, + }, + { + name: "ReleaseEvent", + event: ReleaseEvent, + typ: ReleasePayload{}, + filename: "../testdata/gitea/release-event.json", + headers: http.Header{ + "X-Gitea-Event": []string{"release"}, + "X-Gitea-Signature": []string{"847fcef001c2e59dadac3fa5fa01ca26c9985a5faa10e48a9868a8ad98e9dd18"}, + }, + }, + } + + for _, tt := range tests { + tc := tt + client := &http.Client{} + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + payload, err := os.Open(tc.filename) + assert.NoError(err) + defer func() { + _ = payload.Close() + }() + + var parseError error + var results interface{} + server := newServer(func(w http.ResponseWriter, r *http.Request) { + results, parseError = hook.Parse(r, tc.event) + }) + defer server.Close() + req, err := http.NewRequest(http.MethodPost, server.URL+path, payload) + assert.NoError(err) + req.Header = tc.headers + req.Header.Set("Content-Type", "application/json") + + resp, err := client.Do(req) + assert.NoError(err) + assert.Equal(http.StatusOK, resp.StatusCode) + assert.NoError(parseError) + assert.Equal(reflect.TypeOf(tc.typ), reflect.TypeOf(results)) + }) + } +} diff --git a/gitea/payload.go b/gitea/payload.go new file mode 100644 index 0000000..9191604 --- /dev/null +++ b/gitea/payload.go @@ -0,0 +1,403 @@ +package gitea + +import "time" + +// PayloadUser represents the author or committer of a commit +type PayloadUser struct { + Name string `json:"name"` + Email string `json:"email"` + UserName string `json:"username"` +} + +// PayloadCommitVerification represents the GPG verification of a commit +type PayloadCommitVerification struct { + Verified bool `json:"verified"` + Reason string `json:"reason"` + Signature string `json:"signature"` + Signer *PayloadUser `json:"signer"` + Payload string `json:"payload"` +} + +// PayloadCommit represents a commit +type PayloadCommit struct { + // sha1 hash of the commit + ID string `json:"id"` + Message string `json:"message"` + URL string `json:"url"` + Author *PayloadUser `json:"author"` + Committer *PayloadUser `json:"committer"` + Verification *PayloadCommitVerification `json:"verification"` + // swagger:strfmt date-time + Timestamp time.Time `json:"timestamp"` + Added []string `json:"added"` + Removed []string `json:"removed"` + Modified []string `json:"modified"` +} + +// Repository represents a repository +type Repository struct { + ID int64 `json:"id"` + Owner *User `json:"owner"` + Name string `json:"name"` + FullName string `json:"full_name"` + Description string `json:"description"` + Empty bool `json:"empty"` + Private bool `json:"private"` + Fork bool `json:"fork"` + Template bool `json:"template"` + Parent *Repository `json:"parent"` + Mirror bool `json:"mirror"` + Size int `json:"size"` + HTMLURL string `json:"html_url"` + SSHURL string `json:"ssh_url"` + CloneURL string `json:"clone_url"` + OriginalURL string `json:"original_url"` + Website string `json:"website"` + Stars int `json:"stars_count"` + Forks int `json:"forks_count"` + Watchers int `json:"watchers_count"` + OpenIssues int `json:"open_issues_count"` + OpenPulls int `json:"open_pr_counter"` + Releases int `json:"release_counter"` + DefaultBranch string `json:"default_branch"` + Archived bool `json:"archived"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` + Permissions *Permission `json:"permissions,omitempty"` + HasIssues bool `json:"has_issues"` + InternalTracker *InternalTracker `json:"internal_tracker,omitempty"` + ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"` + HasWiki bool `json:"has_wiki"` + ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"` + HasPullRequests bool `json:"has_pull_requests"` + HasProjects bool `json:"has_projects"` + IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"` + AllowMerge bool `json:"allow_merge_commits"` + AllowRebase bool `json:"allow_rebase"` + AllowRebaseMerge bool `json:"allow_rebase_explicit"` + AllowSquash bool `json:"allow_squash_merge"` + DefaultMergeStyle string `json:"default_merge_style"` + AvatarURL string `json:"avatar_url"` + Internal bool `json:"internal"` + MirrorInterval string `json:"mirror_interval"` +} + +// User represents a user +type User struct { + ID int64 `json:"id"` + UserName string `json:"login"` + FullName string `json:"full_name"` + Email string `json:"email"` + AvatarURL string `json:"avatar_url"` + Language string `json:"language"` + IsAdmin bool `json:"is_admin"` + LastLogin time.Time `json:"last_login,omitempty"` + Created time.Time `json:"created,omitempty"` + Restricted bool `json:"restricted"` + IsActive bool `json:"active"` + ProhibitLogin bool `json:"prohibit_login"` + Location string `json:"location"` + Website string `json:"website"` + Description string `json:"description"` + Visibility string `json:"visibility"` + Followers int `json:"followers_count"` + Following int `json:"following_count"` + StarredRepos int `json:"starred_repos_count"` +} + +// Permission represents a set of permissions +type Permission struct { + Admin bool `json:"admin"` + Push bool `json:"push"` + Pull bool `json:"pull"` +} + +// InternalTracker represents settings for internal tracker +type InternalTracker struct { + EnableTimeTracker bool `json:"enable_time_tracker"` + AllowOnlyContributorsToTrackTime bool `json:"allow_only_contributors_to_track_time"` + EnableIssueDependencies bool `json:"enable_issue_dependencies"` +} + +// ExternalTracker represents settings for external tracker +type ExternalTracker struct { + ExternalTrackerURL string `json:"external_tracker_url"` + ExternalTrackerFormat string `json:"external_tracker_format"` + ExternalTrackerStyle string `json:"external_tracker_style"` +} + +// ExternalWiki represents setting for external wiki +type ExternalWiki struct { + ExternalWikiURL string `json:"external_wiki_url"` +} + +// PusherType define the type to push +type PusherType string + +// HookIssueCommentAction defines hook issue comment action +type HookIssueCommentAction string + +// Issue represents an issue in a repository +type Issue struct { + ID int64 `json:"id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + Index int64 `json:"number"` + Poster *User `json:"user"` + OriginalAuthor string `json:"original_author"` + OriginalAuthorID int64 `json:"original_author_id"` + Title string `json:"title"` + Body string `json:"body"` + Ref string `json:"ref"` + Labels []*Label `json:"labels"` + Milestone *Milestone `json:"milestone"` + Assignee *User `json:"assignee"` + Assignees []*User `json:"assignees"` + State StateType `json:"state"` + IsLocked bool `json:"is_locked"` + Comments int `json:"comments"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` + Closed *time.Time `json:"closed_at"` + Deadline *time.Time `json:"due_date"` + PullRequest *PullRequestMeta `json:"pull_request"` + Repo *RepositoryMeta `json:"repository"` +} + +// Label a label to an issue or a pr +type Label struct { + ID int64 `json:"id"` + Name string `json:"name"` + Color string `json:"color"` + Description string `json:"description"` + URL string `json:"url"` +} + +// Milestone milestone is a collection of issues on one repository +type Milestone struct { + ID int64 `json:"id"` + Title string `json:"title"` + Description string `json:"description"` + State StateType `json:"state"` + OpenIssues int `json:"open_issues"` + ClosedIssues int `json:"closed_issues"` + Created time.Time `json:"created_at"` + Updated *time.Time `json:"updated_at"` + Closed *time.Time `json:"closed_at"` + Deadline *time.Time `json:"due_on"` +} + +// StateType issue state type +type StateType string + +// PullRequestMeta PR info if an issue is a PR +type PullRequestMeta struct { + HasMerged bool `json:"merged"` + Merged *time.Time `json:"merged_at"` +} + +// RepositoryMeta basic repository information +type RepositoryMeta struct { + ID int64 `json:"id"` + Name string `json:"name"` + Owner string `json:"owner"` + FullName string `json:"full_name"` +} + +// CreatePayload represents a payload create reposoitory +type CreatePayload struct { + Sha string `json:"sha"` + Ref string `json:"ref"` + RefType string `json:"ref_type"` + Repo *Repository `json:"repository"` + Sender *User `json:"sender"` +} + +// DeletePayload represents delete payload +type DeletePayload struct { + Ref string `json:"ref"` + RefType string `json:"ref_type"` + PusherType PusherType `json:"pusher_type"` + Repo *Repository `json:"repository"` + Sender *User `json:"sender"` +} + +// ForkPayload represents fork payload +type ForkPayload struct { + Forkee *Repository `json:"forkee"` + Repo *Repository `json:"repository"` + Sender *User `json:"sender"` +} + +// IssueCommentPayload represents a payload information of issue comment event. +type IssueCommentPayload struct { + Action HookIssueCommentAction `json:"action"` + Issue *Issue `json:"issue"` + Comment *Comment `json:"comment"` + Changes *ChangesPayload `json:"changes,omitempty"` + Repository *Repository `json:"repository"` + Sender *User `json:"sender"` + IsPull bool `json:"is_pull"` +} + +// ChangesPayload represents the payload information of issue change +type ChangesPayload struct { + Title *ChangesFromPayload `json:"title,omitempty"` + Body *ChangesFromPayload `json:"body,omitempty"` + Ref *ChangesFromPayload `json:"ref,omitempty"` +} + +// ChangesFromPayload FIXME +type ChangesFromPayload struct { + From string `json:"from"` +} + +// Comment represents a comment on a commit or issue +type Comment struct { + ID int64 `json:"id"` + HTMLURL string `json:"html_url"` + PRURL string `json:"pull_request_url"` + IssueURL string `json:"issue_url"` + Poster *User `json:"user"` + OriginalAuthor string `json:"original_author"` + OriginalAuthorID int64 `json:"original_author_id"` + Body string `json:"body"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` +} + +// PushPayload represents a payload information of push event. +type PushPayload struct { + Ref string `json:"ref"` + Before string `json:"before"` + After string `json:"after"` + CompareURL string `json:"compare_url"` + Commits []*PayloadCommit `json:"commits"` + HeadCommit *PayloadCommit `json:"head_commit"` + Repo *Repository `json:"repository"` + Pusher *User `json:"pusher"` + Sender *User `json:"sender"` +} + +// PullRequestPayload represents a payload information of pull request event. +type PullRequestPayload struct { + Action HookIssueAction `json:"action"` + Index int64 `json:"number"` + Changes *ChangesPayload `json:"changes,omitempty"` + PullRequest *PullRequest `json:"pull_request"` + Repository *Repository `json:"repository"` + Sender *User `json:"sender"` + Review *ReviewPayload `json:"review"` +} + +// HookIssueAction FIXME +type HookIssueAction string + +// PullRequest represents a pull request +type PullRequest struct { + ID int64 `json:"id"` + URL string `json:"url"` + Index int64 `json:"number"` + Poster *User `json:"user"` + Title string `json:"title"` + Body string `json:"body"` + Labels []*Label `json:"labels"` + Milestone *Milestone `json:"milestone"` + Assignee *User `json:"assignee"` + Assignees []*User `json:"assignees"` + State StateType `json:"state"` + IsLocked bool `json:"is_locked"` + Comments int `json:"comments"` + HTMLURL string `json:"html_url"` + DiffURL string `json:"diff_url"` + PatchURL string `json:"patch_url"` + Mergeable bool `json:"mergeable"` + HasMerged bool `json:"merged"` + Merged *time.Time `json:"merged_at"` + MergedCommitID *string `json:"merge_commit_sha"` + MergedBy *User `json:"merged_by"` + Base *PRBranchInfo `json:"base"` + Head *PRBranchInfo `json:"head"` + MergeBase string `json:"merge_base"` + Deadline *time.Time `json:"due_date"` + Created *time.Time `json:"created_at"` + Updated *time.Time `json:"updated_at"` + Closed *time.Time `json:"closed_at"` +} + +// PRBranchInfo information about a branch +type PRBranchInfo struct { + Name string `json:"label"` + Ref string `json:"ref"` + Sha string `json:"sha"` + RepoID int64 `json:"repo_id"` + Repository *Repository `json:"repo"` +} + +// ReviewPayload FIXME +type ReviewPayload struct { + Type string `json:"type"` + Content string `json:"content"` +} + +// RepositoryPayload payload for repository webhooks +type RepositoryPayload struct { + Action HookRepoAction `json:"action"` + Repository *Repository `json:"repository"` + Organization *User `json:"organization"` + Sender *User `json:"sender"` +} + +// HookRepoAction an action that happens to a repo +type HookRepoAction string + +// ReleasePayload represents a payload information of release event. +type ReleasePayload struct { + Action HookReleaseAction `json:"action"` + Release *Release `json:"release"` + Repository *Repository `json:"repository"` + Sender *User `json:"sender"` +} + +// Release represents a repository release +type Release struct { + ID int64 `json:"id"` + TagName string `json:"tag_name"` + Target string `json:"target_commitish"` + Title string `json:"name"` + Note string `json:"body"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + TarURL string `json:"tarball_url"` + ZipURL string `json:"zipball_url"` + IsDraft bool `json:"draft"` + IsPrerelease bool `json:"prerelease"` + CreatedAt time.Time `json:"created_at"` + PublishedAt time.Time `json:"published_at"` + Publisher *User `json:"author"` + Attachments []*Attachment `json:"assets"` +} + +// HookReleaseAction defines hook release action type +type HookReleaseAction string + +// Attachment a generic attachment +type Attachment struct { + ID int64 `json:"id"` + Name string `json:"name"` + Size int64 `json:"size"` + DownloadCount int64 `json:"download_count"` + Created time.Time `json:"created_at"` + UUID string `json:"uuid"` + DownloadURL string `json:"browser_download_url"` +} + +// IssuePayload represents the payload information that is sent along with an issue event. +type IssuePayload struct { + Action HookIssueAction `json:"action"` + Index int64 `json:"number"` + Changes *ChangesPayload `json:"changes,omitempty"` + Issue *Issue `json:"issue"` + Repository *Repository `json:"repository"` + Sender *User `json:"sender"` +} diff --git a/testdata/gitea/create-event.json b/testdata/gitea/create-event.json new file mode 100644 index 0000000..b258492 --- /dev/null +++ b/testdata/gitea/create-event.json @@ -0,0 +1,102 @@ +{ + "sha": "67b56589a45103f891bdee7c0546e5d40bc02001", + "ref": "master", + "ref_type": "branch", + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": false + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } +} \ No newline at end of file diff --git a/testdata/gitea/delete-event.json b/testdata/gitea/delete-event.json new file mode 100644 index 0000000..2b6187f --- /dev/null +++ b/testdata/gitea/delete-event.json @@ -0,0 +1,102 @@ +{ + "ref": "example3", + "ref_type": "branch", + "pusher_type": "user", + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 114, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:39:18+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": false + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": false, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } +} \ No newline at end of file diff --git a/testdata/gitea/fork-event.json b/testdata/gitea/fork-event.json new file mode 100644 index 0000000..a3ad97d --- /dev/null +++ b/testdata/gitea/fork-event.json @@ -0,0 +1,248 @@ +{ + "forkee": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "repository": { + "id": 2, + "owner": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "name": "example", + "full_name": "example2/example", + "description": "", + "empty": false, + "private": false, + "fork": true, + "template": false, + "parent": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example2/example", + "ssh_url": "git@localhost:example2/example.git", + "clone_url": "http://localhost:3000/example2/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 0, + "open_issues_count": 0, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:28:55+09:00", + "updated_at": "2022-03-09T16:28:55+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + } +} \ No newline at end of file diff --git a/testdata/gitea/issue-assign-event.json b/testdata/gitea/issue-assign-event.json new file mode 100644 index 0000000..92b08c4 --- /dev/null +++ b/testdata/gitea/issue-assign-event.json @@ -0,0 +1,196 @@ +{ + "action": "assigned", + "number": 1, + "issue": { + "id": 1, + "url": "http://localhost:3000/api/v1/repos/example/example/issues/1", + "html_url": "http://localhost:3000/example/example/issues/1", + "number": 1, + "user": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "original_author": "", + "original_author_id": 0, + "title": "example", + "body": "", + "ref": "", + "labels": [], + "milestone": null, + "assignee": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "assignees": [ + { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } + ], + "state": "open", + "is_locked": false, + "comments": 0, + "created_at": "2022-03-09T16:19:00+09:00", + "updated_at": "2022-03-09T16:20:23+09:00", + "closed_at": null, + "due_date": null, + "pull_request": null, + "repository": { + "id": 1, + "name": "example", + "owner": "example", + "full_name": "example/example" + } + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": true, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 76, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:14:29+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } +} \ No newline at end of file diff --git a/testdata/gitea/issue-comment-event.json b/testdata/gitea/issue-comment-event.json new file mode 100644 index 0000000..d6b06ba --- /dev/null +++ b/testdata/gitea/issue-comment-event.json @@ -0,0 +1,229 @@ +{ + "action": "created", + "issue": { + "id": 1, + "url": "http://localhost:3000/api/v1/repos/example/example/issues/1", + "html_url": "http://localhost:3000/example/example/issues/1", + "number": 1, + "user": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "original_author": "", + "original_author_id": 0, + "title": "example", + "body": "", + "ref": "", + "labels": [], + "milestone": null, + "assignee": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "assignees": [ + { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } + ], + "state": "open", + "is_locked": false, + "comments": 0, + "created_at": "2022-03-09T16:19:00+09:00", + "updated_at": "2022-03-09T16:20:44+09:00", + "closed_at": null, + "due_date": null, + "pull_request": null, + "repository": { + "id": 1, + "name": "example", + "owner": "example", + "full_name": "example/example" + } + }, + "comment": { + "id": 2, + "html_url": "http://localhost:3000/example/example/issues/1#issuecomment-2", + "pull_request_url": "", + "issue_url": "http://localhost:3000/example/example/issues/1", + "user": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "original_author": "", + "original_author_id": 0, + "body": "example", + "created_at": "2022-03-09T16:20:44+09:00", + "updated_at": "2022-03-09T16:20:44+09:00" + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": true, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 76, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:14:29+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "is_pull": false +} \ No newline at end of file diff --git a/testdata/gitea/issue-label-event.json b/testdata/gitea/issue-label-event.json new file mode 100644 index 0000000..bf3c36f --- /dev/null +++ b/testdata/gitea/issue-label-event.json @@ -0,0 +1,204 @@ +{ + "action": "label_updated", + "number": 1, + "issue": { + "id": 1, + "url": "http://localhost:3000/api/v1/repos/example/example/issues/1", + "html_url": "http://localhost:3000/example/example/issues/1", + "number": 1, + "user": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "original_author": "", + "original_author_id": 0, + "title": "example", + "body": "", + "ref": "", + "labels": [ + { + "id": 1, + "name": "bug", + "color": "ee0701", + "description": "Something is not working", + "url": "http://localhost:3000/api/v1/repos/example/example/labels/1" + } + ], + "milestone": null, + "assignee": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "assignees": [ + { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } + ], + "state": "open", + "is_locked": false, + "comments": 1, + "created_at": "2022-03-09T16:19:00+09:00", + "updated_at": "2022-03-09T16:21:23+09:00", + "closed_at": null, + "due_date": null, + "pull_request": null, + "repository": { + "id": 1, + "name": "example", + "owner": "example", + "full_name": "example/example" + } + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": true, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 76, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:14:29+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } +} \ No newline at end of file diff --git a/testdata/gitea/issue-milestone-event.json b/testdata/gitea/issue-milestone-event.json new file mode 100644 index 0000000..829dd13 --- /dev/null +++ b/testdata/gitea/issue-milestone-event.json @@ -0,0 +1,215 @@ +{ + "action": "milestoned", + "number": 1, + "issue": { + "id": 1, + "url": "http://localhost:3000/api/v1/repos/example/example/issues/1", + "html_url": "http://localhost:3000/example/example/issues/1", + "number": 1, + "user": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "original_author": "", + "original_author_id": 0, + "title": "example", + "body": "", + "ref": "", + "labels": [ + { + "id": 1, + "name": "bug", + "color": "ee0701", + "description": "Something is not working", + "url": "http://localhost:3000/api/v1/repos/example/example/labels/1" + } + ], + "milestone": { + "id": 1, + "title": "example", + "description": "", + "state": "open", + "open_issues": 1, + "closed_issues": 0, + "created_at": "2022-03-09T16:22:01+09:00", + "updated_at": "2022-03-09T16:22:09+09:00", + "closed_at": null, + "due_on": null + }, + "assignee": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "assignees": [ + { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } + ], + "state": "open", + "is_locked": false, + "comments": 1, + "created_at": "2022-03-09T16:19:00+09:00", + "updated_at": "2022-03-09T16:22:09+09:00", + "closed_at": null, + "due_date": null, + "pull_request": null, + "repository": { + "id": 1, + "name": "example", + "owner": "example", + "full_name": "example/example" + } + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": true, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 76, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:14:29+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } +} \ No newline at end of file diff --git a/testdata/gitea/issues-event.json b/testdata/gitea/issues-event.json new file mode 100644 index 0000000..15269b5 --- /dev/null +++ b/testdata/gitea/issues-event.json @@ -0,0 +1,152 @@ +{ + "action": "opened", + "number": 1, + "issue": { + "id": 1, + "url": "http://localhost:3000/api/v1/repos/example/example/issues/1", + "html_url": "http://localhost:3000/example/example/issues/1", + "number": 1, + "user": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "original_author": "", + "original_author_id": 0, + "title": "example", + "body": "", + "ref": "", + "labels": [], + "milestone": null, + "assignee": null, + "assignees": null, + "state": "open", + "is_locked": false, + "comments": 0, + "created_at": "2022-03-09T16:19:00+09:00", + "updated_at": "2022-03-09T16:19:00+09:00", + "closed_at": null, + "due_date": null, + "pull_request": null, + "repository": { + "id": 1, + "name": "example", + "owner": "example", + "full_name": "example/example" + } + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": true, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 76, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 0, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:14:29+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } +} \ No newline at end of file diff --git a/testdata/gitea/pull-request-assign-event.json b/testdata/gitea/pull-request-assign-event.json new file mode 100644 index 0000000..4a50939 --- /dev/null +++ b/testdata/gitea/pull-request-assign-event.json @@ -0,0 +1,431 @@ +{ + "action": "assigned", + "number": 2, + "pull_request": { + "id": 1, + "url": "http://localhost:3000/example/example/pulls/2", + "number": 2, + "user": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "title": "update", + "body": "", + "labels": [], + "milestone": null, + "assignee": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "assignees": [ + { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } + ], + "state": "open", + "is_locked": false, + "comments": 1, + "html_url": "http://localhost:3000/example/example/pulls/2", + "diff_url": "http://localhost:3000/example/example/pulls/2.diff", + "patch_url": "http://localhost:3000/example/example/pulls/2.patch", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "master", + "ref": "master", + "sha": "67b56589a45103f891bdee7c0546e5d40bc02001", + "repo_id": 1, + "repo": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "head": { + "label": "master", + "ref": "master", + "sha": "48e773f892a831faa47c0a160d1b7f0cd369ae2a", + "repo_id": 2, + "repo": { + "id": 2, + "owner": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "name": "example", + "full_name": "example2/example", + "description": "", + "empty": false, + "private": false, + "fork": true, + "template": false, + "parent": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "mirror": false, + "size": 102, + "html_url": "http://localhost:3000/example2/example", + "ssh_url": "git@localhost:example2/example.git", + "clone_url": "http://localhost:3000/example2/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 0, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:28:55+09:00", + "updated_at": "2022-03-09T16:30:50+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "merge_base": "67b56589a45103f891bdee7c0546e5d40bc02001", + "due_date": null, + "created_at": "2022-03-09T16:31:06+09:00", + "updated_at": "2022-03-09T16:31:59+09:00", + "closed_at": null + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "review": null +} \ No newline at end of file diff --git a/testdata/gitea/pull-request-comment-event.json b/testdata/gitea/pull-request-comment-event.json new file mode 100644 index 0000000..d66ff8e --- /dev/null +++ b/testdata/gitea/pull-request-comment-event.json @@ -0,0 +1,188 @@ +{ + "action": "created", + "issue": { + "id": 2, + "url": "http://localhost:3000/api/v1/repos/example/example/issues/2", + "html_url": "http://localhost:3000/example/example/pulls/2", + "number": 2, + "user": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "original_author": "", + "original_author_id": 0, + "title": "update", + "body": "", + "ref": "", + "labels": [], + "milestone": null, + "assignee": null, + "assignees": null, + "state": "open", + "is_locked": false, + "comments": 0, + "created_at": "2022-03-09T16:31:06+09:00", + "updated_at": "2022-03-09T16:31:34+09:00", + "closed_at": null, + "due_date": null, + "pull_request": { + "merged": false, + "merged_at": null + }, + "repository": { + "id": 1, + "name": "example", + "owner": "example", + "full_name": "example/example" + } + }, + "comment": { + "id": 6, + "html_url": "http://localhost:3000/example/example/pulls/2#issuecomment-6", + "pull_request_url": "http://localhost:3000/example/example/pulls/2", + "issue_url": "", + "user": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "original_author": "", + "original_author_id": 0, + "body": "example", + "created_at": "2022-03-09T16:31:34+09:00", + "updated_at": "2022-03-09T16:31:34+09:00" + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "is_pull": true +} \ No newline at end of file diff --git a/testdata/gitea/pull-request-event.json b/testdata/gitea/pull-request-event.json new file mode 100644 index 0000000..80a09d6 --- /dev/null +++ b/testdata/gitea/pull-request-event.json @@ -0,0 +1,387 @@ +{ + "action": "opened", + "number": 2, + "pull_request": { + "id": 1, + "url": "http://localhost:3000/example/example/pulls/2", + "number": 2, + "user": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "title": "update", + "body": "", + "labels": [], + "milestone": null, + "assignee": null, + "assignees": null, + "state": "open", + "is_locked": false, + "comments": 0, + "html_url": "http://localhost:3000/example/example/pulls/2", + "diff_url": "http://localhost:3000/example/example/pulls/2.diff", + "patch_url": "http://localhost:3000/example/example/pulls/2.patch", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "master", + "ref": "master", + "sha": "67b56589a45103f891bdee7c0546e5d40bc02001", + "repo_id": 1, + "repo": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "head": { + "label": "master", + "ref": "master", + "sha": "48e773f892a831faa47c0a160d1b7f0cd369ae2a", + "repo_id": 2, + "repo": { + "id": 2, + "owner": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "name": "example", + "full_name": "example2/example", + "description": "", + "empty": false, + "private": false, + "fork": true, + "template": false, + "parent": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "mirror": false, + "size": 102, + "html_url": "http://localhost:3000/example2/example", + "ssh_url": "git@localhost:example2/example.git", + "clone_url": "http://localhost:3000/example2/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 0, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:28:55+09:00", + "updated_at": "2022-03-09T16:30:50+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "merge_base": "67b56589a45103f891bdee7c0546e5d40bc02001", + "due_date": null, + "created_at": "2022-03-09T16:31:06+09:00", + "updated_at": "2022-03-09T16:31:06+09:00", + "closed_at": null + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "review": null +} \ No newline at end of file diff --git a/testdata/gitea/pull-request-label-event.json b/testdata/gitea/pull-request-label-event.json new file mode 100644 index 0000000..d91cb6d --- /dev/null +++ b/testdata/gitea/pull-request-label-event.json @@ -0,0 +1,439 @@ +{ + "action": "label_updated", + "number": 2, + "pull_request": { + "id": 1, + "url": "http://localhost:3000/example/example/pulls/2", + "number": 2, + "user": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "title": "update", + "body": "", + "labels": [ + { + "id": 1, + "name": "bug", + "color": "ee0701", + "description": "Something is not working", + "url": "http://localhost:3000/api/v1/repos/example/example/labels/1" + } + ], + "milestone": null, + "assignee": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "assignees": [ + { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } + ], + "state": "open", + "is_locked": false, + "comments": 1, + "html_url": "http://localhost:3000/example/example/pulls/2", + "diff_url": "http://localhost:3000/example/example/pulls/2.diff", + "patch_url": "http://localhost:3000/example/example/pulls/2.patch", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "master", + "ref": "master", + "sha": "67b56589a45103f891bdee7c0546e5d40bc02001", + "repo_id": 1, + "repo": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "head": { + "label": "master", + "ref": "master", + "sha": "48e773f892a831faa47c0a160d1b7f0cd369ae2a", + "repo_id": 2, + "repo": { + "id": 2, + "owner": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "name": "example", + "full_name": "example2/example", + "description": "", + "empty": false, + "private": false, + "fork": true, + "template": false, + "parent": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "mirror": false, + "size": 102, + "html_url": "http://localhost:3000/example2/example", + "ssh_url": "git@localhost:example2/example.git", + "clone_url": "http://localhost:3000/example2/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 0, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:28:55+09:00", + "updated_at": "2022-03-09T16:30:50+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "merge_base": "67b56589a45103f891bdee7c0546e5d40bc02001", + "due_date": null, + "created_at": "2022-03-09T16:31:06+09:00", + "updated_at": "2022-03-09T16:32:19+09:00", + "closed_at": null + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": false + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "review": null +} \ No newline at end of file diff --git a/testdata/gitea/pull-request-milestone-event.json b/testdata/gitea/pull-request-milestone-event.json new file mode 100644 index 0000000..61fbf22 --- /dev/null +++ b/testdata/gitea/pull-request-milestone-event.json @@ -0,0 +1,450 @@ +{ + "action": "milestoned", + "number": 2, + "pull_request": { + "id": 1, + "url": "http://localhost:3000/example/example/pulls/2", + "number": 2, + "user": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "title": "update", + "body": "", + "labels": [ + { + "id": 1, + "name": "bug", + "color": "ee0701", + "description": "Something is not working", + "url": "http://localhost:3000/api/v1/repos/example/example/labels/1" + } + ], + "milestone": { + "id": 1, + "title": "example", + "description": "", + "state": "open", + "open_issues": 2, + "closed_issues": 0, + "created_at": "2022-03-09T16:22:01+09:00", + "updated_at": "2022-03-09T16:32:41+09:00", + "closed_at": null, + "due_on": null + }, + "assignee": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "assignees": [ + { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } + ], + "state": "open", + "is_locked": false, + "comments": 1, + "html_url": "http://localhost:3000/example/example/pulls/2", + "diff_url": "http://localhost:3000/example/example/pulls/2.diff", + "patch_url": "http://localhost:3000/example/example/pulls/2.patch", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "master", + "ref": "master", + "sha": "67b56589a45103f891bdee7c0546e5d40bc02001", + "repo_id": 1, + "repo": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "head": { + "label": "master", + "ref": "master", + "sha": "48e773f892a831faa47c0a160d1b7f0cd369ae2a", + "repo_id": 2, + "repo": { + "id": 2, + "owner": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "name": "example", + "full_name": "example2/example", + "description": "", + "empty": false, + "private": false, + "fork": true, + "template": false, + "parent": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "mirror": false, + "size": 102, + "html_url": "http://localhost:3000/example2/example", + "ssh_url": "git@localhost:example2/example.git", + "clone_url": "http://localhost:3000/example2/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 0, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:28:55+09:00", + "updated_at": "2022-03-09T16:30:50+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "merge_base": "67b56589a45103f891bdee7c0546e5d40bc02001", + "due_date": null, + "created_at": "2022-03-09T16:31:06+09:00", + "updated_at": "2022-03-09T16:32:41+09:00", + "closed_at": null + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "review": null +} \ No newline at end of file diff --git a/testdata/gitea/pull-request-review-event.json b/testdata/gitea/pull-request-review-event.json new file mode 100644 index 0000000..e68c2b9 --- /dev/null +++ b/testdata/gitea/pull-request-review-event.json @@ -0,0 +1,453 @@ +{ + "action": "reviewed", + "number": 2, + "pull_request": { + "id": 1, + "url": "http://localhost:3000/example/example/pulls/2", + "number": 2, + "user": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "title": "update", + "body": "", + "labels": [ + { + "id": 1, + "name": "bug", + "color": "ee0701", + "description": "Something is not working", + "url": "http://localhost:3000/api/v1/repos/example/example/labels/1" + } + ], + "milestone": { + "id": 1, + "title": "example", + "description": "", + "state": "open", + "open_issues": 2, + "closed_issues": 0, + "created_at": "2022-03-09T16:22:01+09:00", + "updated_at": "2022-03-09T16:32:41+09:00", + "closed_at": null, + "due_on": null + }, + "assignee": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "assignees": [ + { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } + ], + "state": "open", + "is_locked": false, + "comments": 1, + "html_url": "http://localhost:3000/example/example/pulls/2", + "diff_url": "http://localhost:3000/example/example/pulls/2.diff", + "patch_url": "http://localhost:3000/example/example/pulls/2.patch", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "master", + "ref": "master", + "sha": "67b56589a45103f891bdee7c0546e5d40bc02001", + "repo_id": 1, + "repo": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "head": { + "label": "master", + "ref": "master", + "sha": "48e773f892a831faa47c0a160d1b7f0cd369ae2a", + "repo_id": 2, + "repo": { + "id": 2, + "owner": { + "id": 2, + "login": "example2", + "full_name": "", + "email": "example2@example2.com", + "avatar_url": "http://localhost:3000/avatar/1686726945d0ffb4706d7a722ff6f244", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:26:02+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example2" + }, + "name": "example", + "full_name": "example2/example", + "description": "", + "empty": false, + "private": false, + "fork": true, + "template": false, + "parent": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "mirror": false, + "size": 102, + "html_url": "http://localhost:3000/example2/example", + "ssh_url": "git@localhost:example2/example.git", + "clone_url": "http://localhost:3000/example2/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 0, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:28:55+09:00", + "updated_at": "2022-03-09T16:30:50+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + } + }, + "merge_base": "67b56589a45103f891bdee7c0546e5d40bc02001", + "due_date": null, + "created_at": "2022-03-09T16:31:06+09:00", + "updated_at": "2022-03-09T16:36:51+09:00", + "closed_at": null + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 1, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 1, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "review": { + "type": "pull_request_comment", + "content": "123" + } +} \ No newline at end of file diff --git a/testdata/gitea/push-event.json b/testdata/gitea/push-event.json new file mode 100644 index 0000000..15385df --- /dev/null +++ b/testdata/gitea/push-event.json @@ -0,0 +1,171 @@ +{ + "ref": "refs/heads/master", + "before": "0000000000000000000000000000000000000000", + "after": "67b56589a45103f891bdee7c0546e5d40bc02001", + "compare_url": "http://localhost:3000/example/example/compare/0000000000000000000000000000000000000000...67b56589a45103f891bdee7c0546e5d40bc02001", + "commits": [ + { + "id": "67b56589a45103f891bdee7c0546e5d40bc02001", + "message": "example\n", + "url": "http://localhost:3000/example/example/commit/67b56589a45103f891bdee7c0546e5d40bc02001", + "author": { + "name": "example", + "email": "example@example.com", + "username": "" + }, + "committer": { + "name": "example", + "email": "example@example.com", + "username": "" + }, + "verification": null, + "timestamp": "2022-03-09T16:23:39+09:00", + "added": [ + "example" + ], + "removed": [], + "modified": [] + } + ], + "head_commit": { + "id": "67b56589a45103f891bdee7c0546e5d40bc02001", + "message": "example\n", + "url": "http://localhost:3000/example/example/commit/67b56589a45103f891bdee7c0546e5d40bc02001", + "author": { + "name": "example", + "email": "example@example.com", + "username": "" + }, + "committer": { + "name": "example", + "email": "example@example.com", + "username": "" + }, + "verification": null, + "timestamp": "2022-03-09T16:23:39+09:00", + "added": [ + "example" + ], + "removed": [], + "modified": [] + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "pusher": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } +} \ No newline at end of file diff --git a/testdata/gitea/release-event.json b/testdata/gitea/release-event.json new file mode 100644 index 0000000..487c707 --- /dev/null +++ b/testdata/gitea/release-event.json @@ -0,0 +1,138 @@ +{ + "action": "published", + "release": { + "id": 1, + "tag_name": "example", + "target_commitish": "master", + "name": "0.0.0", + "body": "", + "url": "http://localhost:3000/api/v1/repos/example/example/releases/1", + "html_url": "http://localhost:3000/example/example/releases/tag/example", + "tarball_url": "http://localhost:3000/example/example/archive/example.tar.gz", + "zipball_url": "http://localhost:3000/example/example/archive/example.zip", + "draft": false, + "prerelease": false, + "created_at": "2022-03-09T16:25:04+09:00", + "published_at": "2022-03-09T16:25:04+09:00", + "author": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "assets": [] + }, + "repository": { + "id": 1, + "owner": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + }, + "name": "example", + "full_name": "example/example", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 89, + "html_url": "http://localhost:3000/example/example", + "ssh_url": "git@localhost:example/example.git", + "clone_url": "http://localhost:3000/example/example.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 1, + "open_pr_counter": 0, + "release_counter": 1, + "default_branch": "master", + "archived": false, + "created_at": "2022-03-09T16:14:29+09:00", + "updated_at": "2022-03-09T16:23:53+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } +} \ No newline at end of file diff --git a/testdata/gitea/repository-event.json b/testdata/gitea/repository-event.json new file mode 100644 index 0000000..718d5f9 --- /dev/null +++ b/testdata/gitea/repository-event.json @@ -0,0 +1,122 @@ +{ + "action": "created", + "repository": { + "id": 5, + "owner": { + "id": 3, + "login": "example3", + "full_name": "", + "email": "", + "avatar_url": "http://localhost:3000/avatars/c458fb5edb84c54f4dc42804622aa0c5", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:50:14+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example3" + }, + "name": "example5", + "full_name": "example3/example5", + "description": "", + "empty": true, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 0, + "html_url": "http://localhost:3000/example3/example5", + "ssh_url": "git@localhost:example3/example5.git", + "clone_url": "http://localhost:3000/example3/example5.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 0, + "open_issues_count": 0, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "", + "archived": false, + "created_at": "2022-03-09T16:50:53+09:00", + "updated_at": "2022-03-09T16:50:53+09:00", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": true, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "has_pull_requests": true, + "has_projects": true, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "default_merge_style": "merge", + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null + }, + "organization": { + "id": 3, + "login": "example3", + "full_name": "", + "email": "", + "avatar_url": "http://localhost:3000/avatars/c458fb5edb84c54f4dc42804622aa0c5", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:50:14+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example3" + }, + "sender": { + "id": 1, + "login": "example", + "full_name": "", + "email": "example@example.com", + "avatar_url": "http://localhost:3000/avatar/23463b99b62a72f26ed677cc556c44e8", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2022-03-09T16:14:22+09:00", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "website": "", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "example" + } +} \ No newline at end of file