From 2755e3cb78f22cd75c727f3a66f14673c1e290fe Mon Sep 17 00:00:00 2001 From: Clement Li Date: Sat, 16 Apr 2022 17:32:16 +0800 Subject: [PATCH] Add Chinese code platform gitee webhooks --- gitee/gitee.go | 162 +++++ gitee/gitee_test.go | 222 +++++++ gitee/payload.go | 289 +++++++++ testdata/gitee/comment-commit-event.json | 236 +++++++ testdata/gitee/comment-issue-event.json | 236 +++++++ .../gitee/comment-merge-request-event.json | 236 +++++++ testdata/gitee/issue-event.json | 234 +++++++ testdata/gitee/merge-request-event.json | 609 ++++++++++++++++++ testdata/gitee/push-event.json | 215 +++++++ testdata/gitee/tag-event.json | 215 +++++++ 10 files changed, 2654 insertions(+) create mode 100644 gitee/gitee.go create mode 100644 gitee/gitee_test.go create mode 100644 gitee/payload.go create mode 100644 testdata/gitee/comment-commit-event.json create mode 100644 testdata/gitee/comment-issue-event.json create mode 100644 testdata/gitee/comment-merge-request-event.json create mode 100644 testdata/gitee/issue-event.json create mode 100644 testdata/gitee/merge-request-event.json create mode 100644 testdata/gitee/push-event.json create mode 100644 testdata/gitee/tag-event.json diff --git a/gitee/gitee.go b/gitee/gitee.go new file mode 100644 index 0000000..9599272 --- /dev/null +++ b/gitee/gitee.go @@ -0,0 +1,162 @@ +package gitee + +import ( + "encoding/json" + "errors" + "fmt" + "io" + "io/ioutil" + "net/http" +) + +// parse errors +var ( + ErrMethodNotAllowed = errors.New("method not allowed") + ErrMissingEvents = errors.New("missing X-Gitee-Events") + ErrMissingEventHeader = errors.New("missing X-Gitee-Event Header") + ErrMissingTimestampHeader = errors.New("missing X-Gitee-Timestamp Header") + ErrMissingToken = errors.New("missing X-Gitee-Token") + ErrContentType = errors.New("hook only accepts content-type: application/json") + ErrRequestBody = errors.New("failed to read request body") + ErrGiteeTokenVerificationFailed = errors.New("failed to verify token") + ErrParsingPayload = errors.New("failed to parsing payload") + ErrEventNotFound = errors.New("failed to find event") + // ErrHMACVerificationFailed = errors.New("HMAC verification failed") +) + +// Gitee hook types +const ( + PushEvents Event = "Push Hook" + TagEvents Event = "Tag Push Hook" + IssuesEvents Event = "Issue Hook" + CommentEvents Event = "Note Hook" + MergeRequestEvents Event = "Merge Request Hook" +) + +// 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 Gitee 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 Gitee hook event type by the X-Gitee-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, ErrMissingEvents + } + if r.Method != http.MethodPost { + return nil, ErrMethodNotAllowed + } + + timeStamp := r.Header.Get("X-Gitee-Timestamp") + if len(timeStamp) == 0 { + return nil, ErrMissingTimestampHeader + } + + contentType := r.Header.Get("content-type") + if contentType != "application/json" { + return nil, ErrContentType + } + + event := r.Header.Get("X-Gitee-Event") + if len(event) == 0 { + return nil, ErrMissingEventHeader + } + + giteeEvent := Event(event) + + 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-Gitee-Token") + if signature != hook.secret { + return nil, ErrGiteeTokenVerificationFailed + } + } + + return eventParsing(giteeEvent, events, payload) +} + +func eventParsing(giteeEvent Event, events []Event, payload []byte) (interface{}, error) { + + var found bool + for _, evt := range events { + if evt == giteeEvent { + found = true + break + } + } + // event not defined to be parsed + if !found { + return nil, ErrEventNotFound + } + + switch giteeEvent { + case PushEvents: + var pl PushEventPayload + err := json.Unmarshal([]byte(payload), &pl) + return pl, err + + case TagEvents: + var pl TagEventPayload + err := json.Unmarshal([]byte(payload), &pl) + return pl, err + + case IssuesEvents: + var pl IssueEventPayload + err := json.Unmarshal([]byte(payload), &pl) + return pl, err + + case CommentEvents: + var pl CommentEventPayload + err := json.Unmarshal([]byte(payload), &pl) + return pl, err + + case MergeRequestEvents: + var pl MergeRequestEventPayload + err := json.Unmarshal([]byte(payload), &pl) + return pl, err + + default: + return nil, fmt.Errorf("unknown event %s", giteeEvent) + } +} diff --git a/gitee/gitee_test.go b/gitee/gitee_test.go new file mode 100644 index 0000000..41b1a05 --- /dev/null +++ b/gitee/gitee_test.go @@ -0,0 +1,222 @@ +package gitee + +import ( + "bytes" + "io" + "log" + "net/http" + "net/http/httptest" + "os" + "reflect" + "testing" + + "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("sampleToken!")) + 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: PushEvents, + payload: bytes.NewBuffer([]byte("{}")), + headers: http.Header{}, + }, + { + name: "UnsubscribedEvent", + event: PushEvents, + payload: bytes.NewBuffer([]byte("{}")), + headers: http.Header{ + "X-Gitee-Event": []string{"noneexistant_event"}, + }, + }, + { + name: "BadBody", + event: PushEvents, + payload: bytes.NewBuffer([]byte("")), + headers: http.Header{ + "X-Gitee-Event": []string{"Push Hook"}, + "X-Gitee-Token": []string{"sampleToken!"}, + }, + }, + { + name: "TokenMismatch", + event: PushEvents, + payload: bytes.NewBuffer([]byte("{}")), + headers: http.Header{ + "X-Gitee-Event": []string{"Push Hook"}, + "X-Gitee-Token": []string{"badsampleToken!!"}, + }, + }, + } + + 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: "PushEvent", + event: PushEvents, + typ: PushEventPayload{}, + filename: "../testdata/gitee/push-event.json", + headers: http.Header{ + "X-Gitee-Event": []string{"Push Hook"}, + }, + }, + { + name: "TagEvent", + event: TagEvents, + typ: TagEventPayload{}, + filename: "../testdata/gitee/tag-event.json", + headers: http.Header{ + "X-Gitee-Event": []string{"Tag Push Hook"}, + }, + }, + { + name: "IssueEvent", + event: IssuesEvents, + typ: IssueEventPayload{}, + filename: "../testdata/gitee/issue-event.json", + headers: http.Header{ + "X-Gitee-Event": []string{"Issue Hook"}, + }, + }, + { + name: "CommentCommitEvent", + event: CommentEvents, + typ: CommentEventPayload{}, + filename: "../testdata/gitee/comment-commit-event.json", + headers: http.Header{ + "X-Gitee-Event": []string{"Note Hook"}, + }, + }, + { + name: "CommentMergeRequestEvent", + event: CommentEvents, + typ: CommentEventPayload{}, + filename: "../testdata/gitee/comment-merge-request-event.json", + headers: http.Header{ + "X-Gitee-Event": []string{"Note Hook"}, + }, + }, + { + name: "CommentIssueEvent", + event: CommentEvents, + typ: CommentEventPayload{}, + filename: "../testdata/gitee/comment-issue-event.json", + headers: http.Header{ + "X-Gitee-Event": []string{"Note Hook"}, + }, + }, + { + name: "MergeRequestEvent", + event: MergeRequestEvents, + typ: MergeRequestEventPayload{}, + filename: "../testdata/gitee/merge-request-event.json", + headers: http.Header{ + "X-Gitee-Event": []string{"Merge Request Hook"}, + }, + }, + } + + 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") + req.Header.Set("X-Gitee-Token", "sampleToken!") + req.Header.Set("X-Gitee-TimeStamp", "1650090527447") + + 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/gitee/payload.go b/gitee/payload.go new file mode 100644 index 0000000..4dd7310 --- /dev/null +++ b/gitee/payload.go @@ -0,0 +1,289 @@ +package gitee + +import ( + "time" +) + +type CommentEventPayload struct { + Action string `json:"action"` + Comment NoteHook `json:"comment"` + Repository ProjectHook `json:"repository"` + Project ProjectHook `json:"project"` + Author UserHook `json:"author"` + Sender UserHook `json:"sender"` + URL string `json:"url"` + Note string `json:"note"` + NoteableType string `json:"noteable_type"` + NoteableID int64 `json:"noteable_id"` + Title string `json:"title"` + PerIID string `json:"per_iid"` + ShortCommitID string `json:"short_commit_id"` + Enterprise EnterpriseHook `json:"enterprise"` + PullRequest PullRequestHook `json:"pull_request"` + Issue IssueHook `json:"issue"` + HookName string `json:"hook_name"` + Password string `json:"password"` +} + +type PushEventPayload struct { + Ref string `json:"ref"` + Before string `json:"before"` + After string `json:"after"` + TotalCommitsCount int64 `json:"total_commits_count"` + CommitsMoreThanTen bool `json:"commits_more_than_ten"` + Created bool `json:"created"` + Deleted bool `json:"deleted"` + Compare string `json:"compare"` + Commits []CommitHook `json:"commits"` + HeadCommit CommitHook `json:"head_commit"` + Repository ProjectHook `json:"repository"` + Project ProjectHook `json:"project"` + UserID int64 `json:"user_id"` + UserName string `json:"user_name"` + User UserHook `json:"user"` + Pusher UserHook `json:"pusher"` + Sender UserHook `json:"sender"` + Enterprise EnterpriseHook `json:"enterprise"` + HookName string `json:"hook_name"` + Password string `json:"password"` +} + +type IssueEventPayload struct { + Action string `json:"action"` + Issue IssueHook `json:"issue"` + Repository ProjectHook `json:"repository"` + Project ProjectHook `json:"project"` + Sender UserHook `json:"sender"` + TargetUser UserHook `json:"target_user"` + User UserHook `json:"user"` + Assignee UserHook `json:"assignee"` + UpdatedBy UserHook `json:"updated_by"` + IID string `json:"iid"` + Title string `json:"title"` + Description string `json:"description"` + State string `json:"state"` + Milestone string `json:"milestone"` + URL string `json:"url"` + Enterprise EnterpriseHook `json:"enterprise"` + HookName string `json:"hook_name"` + Password string `json:"password"` +} + +type MergeRequestEventPayload struct { + Action string `json:"action"` + ActionDesc string `json:"action_desc"` + PullRequest PullRequestHook `json:"pull_request"` + Number int64 `json:"number"` + IID int64 `json:"iid"` + Title string `json:"title"` + Body string `json:"body"` + State string `json:"state"` + MergeStatus string `json:"merge_status"` + MergeCommitSha string `json:"merge_commit_sha"` + URL string `json:"url"` + SourceBranch string `json:"source_branch"` + SourceRepo RepoInfo `json:"source_repo"` + TargetBranch string `json:"target_branch"` + TargetRepo RepoInfo `json:"target_repo"` + Project ProjectHook `json:"project"` + Repository ProjectHook `json:"repository"` + Author UserHook `json:"author"` + UpdatedBy UserHook `json:"updated_by"` + Sender UserHook `json:"sender"` + TargetUser UserHook `json:"target_user"` + Enterprise EnterpriseHook `json:"enterprise"` + HookName string `json:"hook_name"` + Password string `json:"password"` +} + +type TagEventPayload struct { + Action string `json:"action"` +} + +// RepoInfo : Repository information +type RepoInfo struct { + Project ProjectHook `json:"project"` + Repository ProjectHook `json:"repository"` +} + +// LabelHook : Label, issue and pull request labels +type LabelHook struct { + Id int64 `json:"id"` + Name string `json:"name"` + Color string `json:"color"` +} + +// EnterpriseHook : Enterprise information +type EnterpriseHook struct { + Name string `json:"name"` + Url string `json:"url"` +} + +// NoteHook : comment information +type NoteHook struct { + Id int64 `json:"id"` + Body string `json:"body"` + User UserHook `json:"user"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + HtmlUrl string `json:"html_url"` + Position string `json:"position"` + CommitId string `json:"commit_id"` +} + +// UserHook : user information +type UserHook struct { + Id int64 `json:"id"` + Name string `json:"name"` + Email string `json:"email"` + Username string `json:"username"` + UserName string `json:"user_name"` + Url string `json:"url"` + Login string `json:"login"` + AvatarUrl string `json:"avatar_url"` + HtmlUrl string `json:"html_url"` + Type_ string `json:"type"` + SiteAdmin bool `json:"site_admin"` + Time time.Time `json:"time"` + Remark string `json:"remark"` +} + +// CommitHook : git commit information +type CommitHook struct { + Id string `json:"id"` + TreeId string `json:"tree_id"` + ParentIds []string `json:"parent_ids"` + Message string `json:"message"` + Timestamp time.Time `json:"timestamp"` + Url string `json:"url"` + Author UserHook `json:"author"` + Committer UserHook `json:"committer"` + Distinct bool `json:"distinct"` + Added []string `json:"added"` + Removed []string `json:"removed"` + Modified []string `json:"modified"` +} + +// MilestoneHook : milestone information +type MilestoneHook struct { + Id int64 `json:"id"` + HtmlUrl string `json:"html_url"` + Number int64 `json:"number"` + Title string `json:"title"` + Description string `json:"description"` + OpenIssues int64 `json:"open_issues"` + ClosedIssues int64 `json:"closed_issues"` + State string `json:"state"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + DueOn string `json:"due_on"` +} + +// IssueHook : issue information +type IssueHook struct { + Id int64 `json:"id"` + HtmlUrl string `json:"html_url"` + Number string `json:"number"` + Title string `json:"title"` + User UserHook `json:"user"` + Labels []LabelHook `json:"labels"` + State string `json:"state"` + StateName string `json:"state_name"` + TypeName string `json:"type_name"` + Assignee UserHook `json:"assignee"` + Collaborators []UserHook `json:"collaborators"` + Milestone MilestoneHook `json:"milestone"` + Comments int64 `json:"comments"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + Body string `json:"body"` +} + +// ProjectHook : project information +type ProjectHook struct { + Id int64 `json:"id"` + Name string `json:"name"` + Path string `json:"path"` + FullName string `json:"full_name"` + Owner UserHook `json:"owner"` + Private bool `json:"private"` + HtmlUrl string `json:"html_url"` + Url string `json:"url"` + Description string `json:"description"` + Fork bool `json:"fork"` + PushedAt string `json:"pushed_at"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + SshUrl string `json:"ssh_url"` + GitUrl string `json:"git_url"` + CloneUrl string `json:"clone_url"` + SvnUrl string `json:"svn_url"` + GitHttpUrl string `json:"git_http_url"` + GitSshUrl string `json:"git_ssh_url"` + GitSvnUrl string `json:"git_svn_url"` + Homepage string `json:"homepage"` + StargazersCount int64 `json:"stargazers_count"` + WatchersCount int64 `json:"watchers_count"` + ForksCount int64 `json:"forks_count"` + Language string `json:"language"` + + HasIssues bool `json:"has_issues"` + HasWiki bool `json:"has_wiki"` + HasPage bool `json:"has_pages"` + License string `json:"license"` + + OpenIssuesCount int64 `json:"open_issues_count"` + DefaultBranch string `json:"default_branch"` + Namespace string `json:"namespace"` + + NameWithNamespace string `json:"name_with_namespace"` + PathWithNamespace string `json:"path_with_namespace"` +} + +// BranchHook : branch information +type BranchHook struct { + Label string `json:"label"` + Ref string `json:"ref"` + Sha string `json:"sha"` + User *UserHook `json:"user"` + Repo *ProjectHook `json:"repo"` +} + +// PullRequestHook : PR information +type PullRequestHook struct { + Id int64 `json:"id"` + Number int64 `json:"number"` + State string `json:"state"` + HtmlUrl string `json:"html_url"` + DiffUrl string `json:"diff_url"` + PatchUrl string `json:"patch_url"` + Title string `json:"title"` + Body string `json:"body"` + StaleLabels []LabelHook `json:"stale_labels"` + Labels []LabelHook `json:"labels"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + ClosedAt string `json:"closed_at"` + MergedAt string `json:"merged_at"` + MergeCommitSha string `json:"merge_commit_sha"` + MergeReferenceName string `json:"merge_reference_name"` + User UserHook `json:"user"` + Assignee UserHook `json:"assignee"` + Assignees []UserHook `json:"assignees"` + Tester []UserHook `json:"tester"` + Testers []UserHook `json:"testers"` + NeedTest bool `json:"need_test"` + NeedReview bool `json:"need_review"` + Milestone MilestoneHook `json:"milestone"` + Head BranchHook `json:"head"` + Base BranchHook `json:"base"` + Merged bool `json:"merged"` + Mergeable bool `json:"mergeable"` + MergeStatus string `json:"merge_status"` + UpdatedBy UserHook `json:"updated_by"` + Comments int64 `json:"comments"` + Commits int64 `json:"commits"` + Additions int64 `json:"additions"` + Deletions int64 `json:"deletions"` + ChangedFiles int64 `json:"changed_files"` +} diff --git a/testdata/gitee/comment-commit-event.json b/testdata/gitee/comment-commit-event.json new file mode 100644 index 0000000..9d86cd4 --- /dev/null +++ b/testdata/gitee/comment-commit-event.json @@ -0,0 +1,236 @@ +{ + "action": "comment", + "issue": { + "html_url": "https://gitee.com/oschina/git-osc/issues/I1EL99", + "id": 295024870, + "number": "I1EL99", + "title": "这是一条测试 WebHook 接收功能触发的推送", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "labels": [ + { + "id": 827033694, + "name": "bug", + "color": "d73a4a" + } + ], + "state": "open", + "state_name": "待办的", + "type_name": "任务", + "assignee": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "collaborators": [ + { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + } + ], + "milestone": { + "html_url": "https://gitee.com/oschina/gitee/milestones/14143", + "id": 1, + "number": 1, + "title": "问题反馈", + "description": null, + "open_issues": 13, + "closed_issues": 31, + "state": "open", + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "due_on": null + }, + "comments": 0, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "body": "这是一条测试 WebHook 接收功能触发的推送" + }, + "comment": { + "html_url": "https://gitee.com/oschina/git-osc/issues/I1EL99#note_2428569", + "id": 1, + "body": "Fixed", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00" + }, + "repository": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "project": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "author": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "sender": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "url": "https://gitee.com/oschina/git-osc#note_1", + "note": "Fixed", + "title": null, + "noteable_type": "Issue", + "noteable_id": 151, + "per_iid": "#I1EL99", + "short_commit_id": null, + "enterprise": { + "name": "OSCHINA", + "url": "https://gitee.com/oschina" + }, + "hook_name": "note_hooks", + "hook_id": 974410, + "hook_url": "https://gitee.com/clement_li/test12345/hooks/974410/edit", + "password": "test12345", + "timestamp": null, + "sign": "" +} \ No newline at end of file diff --git a/testdata/gitee/comment-issue-event.json b/testdata/gitee/comment-issue-event.json new file mode 100644 index 0000000..9d86cd4 --- /dev/null +++ b/testdata/gitee/comment-issue-event.json @@ -0,0 +1,236 @@ +{ + "action": "comment", + "issue": { + "html_url": "https://gitee.com/oschina/git-osc/issues/I1EL99", + "id": 295024870, + "number": "I1EL99", + "title": "这是一条测试 WebHook 接收功能触发的推送", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "labels": [ + { + "id": 827033694, + "name": "bug", + "color": "d73a4a" + } + ], + "state": "open", + "state_name": "待办的", + "type_name": "任务", + "assignee": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "collaborators": [ + { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + } + ], + "milestone": { + "html_url": "https://gitee.com/oschina/gitee/milestones/14143", + "id": 1, + "number": 1, + "title": "问题反馈", + "description": null, + "open_issues": 13, + "closed_issues": 31, + "state": "open", + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "due_on": null + }, + "comments": 0, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "body": "这是一条测试 WebHook 接收功能触发的推送" + }, + "comment": { + "html_url": "https://gitee.com/oschina/git-osc/issues/I1EL99#note_2428569", + "id": 1, + "body": "Fixed", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00" + }, + "repository": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "project": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "author": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "sender": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "url": "https://gitee.com/oschina/git-osc#note_1", + "note": "Fixed", + "title": null, + "noteable_type": "Issue", + "noteable_id": 151, + "per_iid": "#I1EL99", + "short_commit_id": null, + "enterprise": { + "name": "OSCHINA", + "url": "https://gitee.com/oschina" + }, + "hook_name": "note_hooks", + "hook_id": 974410, + "hook_url": "https://gitee.com/clement_li/test12345/hooks/974410/edit", + "password": "test12345", + "timestamp": null, + "sign": "" +} \ No newline at end of file diff --git a/testdata/gitee/comment-merge-request-event.json b/testdata/gitee/comment-merge-request-event.json new file mode 100644 index 0000000..9d86cd4 --- /dev/null +++ b/testdata/gitee/comment-merge-request-event.json @@ -0,0 +1,236 @@ +{ + "action": "comment", + "issue": { + "html_url": "https://gitee.com/oschina/git-osc/issues/I1EL99", + "id": 295024870, + "number": "I1EL99", + "title": "这是一条测试 WebHook 接收功能触发的推送", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "labels": [ + { + "id": 827033694, + "name": "bug", + "color": "d73a4a" + } + ], + "state": "open", + "state_name": "待办的", + "type_name": "任务", + "assignee": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "collaborators": [ + { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + } + ], + "milestone": { + "html_url": "https://gitee.com/oschina/gitee/milestones/14143", + "id": 1, + "number": 1, + "title": "问题反馈", + "description": null, + "open_issues": 13, + "closed_issues": 31, + "state": "open", + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "due_on": null + }, + "comments": 0, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "body": "这是一条测试 WebHook 接收功能触发的推送" + }, + "comment": { + "html_url": "https://gitee.com/oschina/git-osc/issues/I1EL99#note_2428569", + "id": 1, + "body": "Fixed", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00" + }, + "repository": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "project": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "author": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "sender": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "url": "https://gitee.com/oschina/git-osc#note_1", + "note": "Fixed", + "title": null, + "noteable_type": "Issue", + "noteable_id": 151, + "per_iid": "#I1EL99", + "short_commit_id": null, + "enterprise": { + "name": "OSCHINA", + "url": "https://gitee.com/oschina" + }, + "hook_name": "note_hooks", + "hook_id": 974410, + "hook_url": "https://gitee.com/clement_li/test12345/hooks/974410/edit", + "password": "test12345", + "timestamp": null, + "sign": "" +} \ No newline at end of file diff --git a/testdata/gitee/issue-event.json b/testdata/gitee/issue-event.json new file mode 100644 index 0000000..2b7ac5d --- /dev/null +++ b/testdata/gitee/issue-event.json @@ -0,0 +1,234 @@ +{ + "action": "open", + "issue": { + "html_url": "https://gitee.com/oschina/git-osc/issues/I1EL99", + "id": 295024870, + "number": "I1EL99", + "title": "这是一条测试 WebHook 接收功能触发的推送", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "labels": [ + { + "id": 827033694, + "name": "bug", + "color": "d73a4a" + } + ], + "state": "open", + "state_name": "待办的", + "type_name": "任务", + "assignee": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "collaborators": [ + { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + } + ], + "milestone": { + "html_url": "https://gitee.com/oschina/gitee/milestones/14143", + "id": 1, + "number": 1, + "title": "问题反馈", + "description": null, + "open_issues": 13, + "closed_issues": 31, + "state": "open", + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "due_on": null + }, + "comments": 0, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "body": "这是一条测试 WebHook 接收功能触发的推送" + }, + "repository": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "project": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "sender": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "target_user": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "user": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "assignee": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "updated_by": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "iid": "I1EL99", + "title": "这是一条测试 WebHook 接收功能触发的推送", + "description": "这是一条测试 WebHook 接收功能触发的推送", + "state": "open", + "milestone": "问题反馈", + "url": "https://gitee.com/oschina/git-osc/issues/I1EL99", + "enterprise": { + "name": "OSCHINA", + "url": "https://gitee.com/oschina" + }, + "hook_name": "issue_hooks", + "hook_id": 974410, + "hook_url": "https://gitee.com/clement_li/test12345/hooks/974410/edit", + "password": "test12345", + "timestamp": null, + "sign": "" +} \ No newline at end of file diff --git a/testdata/gitee/merge-request-event.json b/testdata/gitee/merge-request-event.json new file mode 100644 index 0000000..0ea895f --- /dev/null +++ b/testdata/gitee/merge-request-event.json @@ -0,0 +1,609 @@ +{ + "action": "open", + "action_desc": "open", + "pull_request": { + "id": 167750879, + "number": 1, + "state": "open", + "html_url": "https://gitee.com/oschina/git-osc/pulls/6", + "diff_url": "https://gitee.com/oschina/git-osc/pulls/6.diff", + "patch_url": "https://gitee.com/oschina/git-osc/pulls/6.patch", + "title": "这是一条测试 Pull Request 类型 WebHook 触发的推送", + "body": null, + "languages": [ + "Java", + "Ruby" + ], + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "assignee": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "assignees": [ + { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + } + ], + "tester": null, + "testers": [ + + ], + "need_test": false, + "need_review": false, + "milestone": { + "html_url": "https://gitee.com/oschina/gitee/milestones/14143", + "id": 1, + "number": 1, + "title": "问题反馈", + "description": null, + "open_issues": 13, + "closed_issues": 31, + "state": "open", + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "due_on": null + }, + "stale_labels": [ + + ], + "labels": [ + { + "id": 827033694, + "name": "bug", + "color": "d73a4a" + } + ], + "head": { + "label": "gitee:login_should_complete_info", + "ref": "login_should_complete_info", + "sha": "ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "repo": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + } + }, + "base": { + "label": "gitee:master", + "ref": "master", + "sha": "3a6902040b2fd1e240315a84611d36eef14b4f2f", + "user": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "repo": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + } + }, + "merged": false, + "mergeable": null, + "merge_status": "unchecked", + "updated_by": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "comments": 0, + "commits": 1, + "additions": 7, + "deletions": 0, + "changed_files": 1 + }, + "number": 1, + "iid": 1, + "title": "这是一条测试 Pull Request 类型 WebHook 触发的推送", + "body": null, + "languages": [ + "Java", + "Ruby" + ], + "state": "open", + "merge_status": "unchecked", + "merge_commit_sha": "ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "url": "https://gitee.com/oschina/git-osc/pulls/6", + "source_branch": "login_should_complete_info", + "source_repo": { + "project": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "repository": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + } + }, + "target_branch": "master", + "target_repo": { + "project": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "repository": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + } + }, + "project": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "repository": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "author": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "updated_by": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "sender": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "target_user": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "enterprise": { + "name": "OSCHINA", + "url": "https://gitee.com/oschina" + }, + "hook_name": "merge_request_hooks", + "hook_id": 974410, + "hook_url": "https://gitee.com/clement_li/test12345/hooks/974410/edit", + "password": "test12345", + "timestamp": null, + "sign": "" +} \ No newline at end of file diff --git a/testdata/gitee/push-event.json b/testdata/gitee/push-event.json new file mode 100644 index 0000000..5e09ae0 --- /dev/null +++ b/testdata/gitee/push-event.json @@ -0,0 +1,215 @@ +{ + "ref": "refs/heads/test_version", + "before": "3a6902040b2fd1e240315a84611d36eef14b4f2f", + "after": "ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "created": false, + "deleted": false, + "compare": "https://gitee.com/oschina/gitee/compare/3a6902040b2fd1e240315a84611d36eef14b4f2f...ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "commits": [ + { + "id": "3a6902040b2fd1e240315a84611d36eef14b4f2f", + "tree_id": "ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "parent_ids": [ + "ad2f7b1729eea675cd44da48f5e53abdf8f242a8" + ], + "distinct": true, + "message": "这是一条测试 Push 类型 WebHook 触发的推送", + "timestamp": "2020-04-15T21:09:40+08:00", + "url": "https://gitee.com/oschina/gitee/commit/3a6902040b2fd1e240315a84611d36eef14b4f2f", + "author": { + "time": "2020-04-15T21:09:40+08:00", + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "committer": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "added": null, + "removed": null, + "modified": [ + "README.md" + ] + } + ], + "head_commit": { + "id": "3a6902040b2fd1e240315a84611d36eef14b4f2f", + "tree_id": "ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "parent_ids": [ + "ad2f7b1729eea675cd44da48f5e53abdf8f242a8" + ], + "distinct": true, + "message": "这是一条测试 Push 类型 WebHook 触发的推送", + "timestamp": "2020-04-15T21:09:40+08:00", + "url": "https://gitee.com/oschina/gitee/commit/3a6902040b2fd1e240315a84611d36eef14b4f2f", + "author": { + "time": "2020-04-15T21:09:40+08:00", + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "committer": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "added": null, + "removed": null, + "modified": [ + "README.md" + ] + }, + "total_commits_count": 1, + "commits_more_than_ten": false, + "repository": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "project": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "user_id": 1, + "user_name": "Gitee", + "user": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "pusher": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "sender": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "enterprise": { + "name": "OSCHINA", + "url": "https://gitee.com/oschina" + }, + "hook_name": "push_hooks", + "hook_id": 974410, + "hook_url": "https://gitee.com/clement_li/test12345/hooks/974410/edit", + "password": "test12345", + "timestamp": null, + "sign": "" +} \ No newline at end of file diff --git a/testdata/gitee/tag-event.json b/testdata/gitee/tag-event.json new file mode 100644 index 0000000..10ebc6f --- /dev/null +++ b/testdata/gitee/tag-event.json @@ -0,0 +1,215 @@ +{ + "ref": "refs/heads/test_version", + "before": "3a6902040b2fd1e240315a84611d36eef14b4f2f", + "after": "ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "created": false, + "deleted": false, + "compare": "https://gitee.com/oschina/gitee/compare/3a6902040b2fd1e240315a84611d36eef14b4f2f...ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "commits": [ + { + "id": "3a6902040b2fd1e240315a84611d36eef14b4f2f", + "tree_id": "ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "parent_ids": [ + "ad2f7b1729eea675cd44da48f5e53abdf8f242a8" + ], + "distinct": true, + "message": "这是一条测试 Push 类型 WebHook 触发的推送", + "timestamp": "2020-04-15T21:09:40+08:00", + "url": "https://gitee.com/oschina/gitee/commit/3a6902040b2fd1e240315a84611d36eef14b4f2f", + "author": { + "time": "2020-04-15T21:09:40+08:00", + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "committer": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "added": null, + "removed": null, + "modified": [ + "README.md" + ] + } + ], + "head_commit": { + "id": "3a6902040b2fd1e240315a84611d36eef14b4f2f", + "tree_id": "ad2f7b1729eea675cd44da48f5e53abdf8f242a8", + "parent_ids": [ + "ad2f7b1729eea675cd44da48f5e53abdf8f242a8" + ], + "distinct": true, + "message": "这是一条测试 Push 类型 WebHook 触发的推送", + "timestamp": "2020-04-15T21:09:40+08:00", + "url": "https://gitee.com/oschina/gitee/commit/3a6902040b2fd1e240315a84611d36eef14b4f2f", + "author": { + "time": "2020-04-15T21:09:40+08:00", + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "committer": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "added": null, + "removed": null, + "modified": [ + "README.md" + ] + }, + "total_commits_count": 1, + "commits_more_than_ten": false, + "repository": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "project": { + "id": 151, + "name": "Gitee FeedBack", + "path": "git-osc", + "full_name": "oschina/git-osc", + "owner": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "private": false, + "html_url": "https://gitee.com/oschina/git-osc", + "url": "https://gitee.com/oschina/git-osc", + "description": "", + "fork": false, + "created_at": "2020-04-15T21:09:40+08:00", + "updated_at": "2020-04-15T21:09:40+08:00", + "pushed_at": "2020-04-15T21:09:40+08:00", + "git_url": "git://gitee.com:oschina/git-osc.git", + "ssh_url": "git@gitee.com:oschina/git-osc.git", + "clone_url": "https://gitee.com/oschina/git-osc.git", + "svn_url": "svn://gitee.com/oschina/git-osc", + "git_http_url": "https://gitee.com/oschina/git-osc.git", + "git_ssh_url": "git@gitee.com:oschina/git-osc.git", + "git_svn_url": "svn://gitee.com/oschina/git-osc", + "homepage": null, + "stargazers_count": 11, + "watchers_count": 12, + "forks_count": 0, + "language": "ruby", + "has_issues": true, + "has_wiki": true, + "has_pages": false, + "license": null, + "open_issues_count": 0, + "default_branch": "master", + "namespace": "oschina", + "name_with_namespace": "OSCHINA/git-osc", + "path_with_namespace": "oschina/git-osc" + }, + "user_id": 1, + "user_name": "Gitee", + "user": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "pusher": { + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "sender": { + "login": "oschina-org", + "avatar_url": "https://gitee.com/assets/favicon.ico", + "html_url": "https://gitee.com/oschina-org", + "type": "User", + "site_admin": false, + "id": 1, + "name": "Gitee", + "email": "gitee@gitee.com", + "username": "oschina-org", + "user_name": "oschina-org", + "url": "https://gitee.com/oschina-org" + }, + "enterprise": { + "name": "OSCHINA", + "url": "https://gitee.com/oschina" + }, + "hook_name": "tag_push_hooks", + "hook_id": 974410, + "hook_url": "https://gitee.com/clement_li/test12345/hooks/974410/edit", + "password": "test12345", + "timestamp": null, + "sign": "" +} \ No newline at end of file