From ba0004f49c221a21541b76f0bd5361bd8a0468b7 Mon Sep 17 00:00:00 2001 From: Matthew Ruschmann Date: Wed, 21 Dec 2016 01:10:32 -0500 Subject: [PATCH 01/18] Fix typos in create issue comment and edit issue comment API URLs (#57) --- issue_comment.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/issue_comment.go b/issue_comment.go index c766f55..06f1f3b 100644 --- a/issue_comment.go +++ b/issue_comment.go @@ -38,7 +38,7 @@ func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateI return nil, err } comment := new(Comment) - return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/:%s/:%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment) + return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment) } // EditIssueCommentOption is option when editing an issue comment. @@ -53,5 +53,5 @@ func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, op return nil, err } comment := new(Comment) - return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/:%s/:%s/issues/%d/comments/%d", owner, repo, index, commentID), jsonHeader, bytes.NewReader(body), comment) + return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), jsonHeader, bytes.NewReader(body), comment) } From d8e9a397842de601f1fc98ff8c1ca1da18e8be3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Wed, 21 Dec 2016 07:12:03 +0100 Subject: [PATCH 02/18] Implement more issue-endpoints (#50) --- issue.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/issue.go b/issue.go index 7bb50df..8a0cac8 100644 --- a/issue.go +++ b/issue.go @@ -44,6 +44,16 @@ type ListIssueOption struct { Page int } +func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, error) { + issues := make([]*Issue, 0, 10) + return issues, c.getParsedResponse("GET", fmt.Sprintf("/issues?page=%d", opt.Page), nil, nil, &issues) +} + +func (c *Client) ListUserIssues(opt ListIssueOption) ([]*Issue, error) { + issues := make([]*Issue, 0, 10) + return issues, c.getParsedResponse("GET", fmt.Sprintf("/user/issues?page=%d", opt.Page), nil, nil, &issues) +} + func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Issue, error) { issues := make([]*Issue, 0, 10) return issues, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues?page=%d", owner, repo, opt.Page), nil, nil, &issues) From 538bef51cb6ba285e9f536eb6cfdfae57fbe6db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Wed, 21 Dec 2016 07:13:54 +0100 Subject: [PATCH 03/18] GitHub-API compliance (#52) * Fix #3653 * GitHub Compliance --- issue.go | 3 ++- issue_label.go | 1 + user.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/issue.go b/issue.go index 8a0cac8..aa2f0d8 100644 --- a/issue.go +++ b/issue.go @@ -41,7 +41,8 @@ type Issue struct { } type ListIssueOption struct { - Page int + Page int + State string } func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, error) { diff --git a/issue_label.go b/issue_label.go index ce6a64d..b8ff300 100644 --- a/issue_label.go +++ b/issue_label.go @@ -14,6 +14,7 @@ type Label struct { ID int64 `json:"id"` Name string `json:"name"` Color string `json:"color"` + URL string `json:"url"` } func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) { diff --git a/user.go b/user.go index 0bf2254..564a3fb 100644 --- a/user.go +++ b/user.go @@ -11,7 +11,7 @@ import ( // User represents a API user. type User struct { ID int64 `json:"id"` - UserName string `json:"username"` + UserName string `json:"login"` FullName string `json:"full_name"` Email string `json:"email"` AvatarUrl string `json:"avatar_url"` From 2a7c1a16337117b1b62e219b43286a6ea2ec2ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Wed, 21 Dec 2016 07:15:00 +0100 Subject: [PATCH 04/18] More Issue-Comments API-endpoints (gogs/#3624) (#48) * Issue-comments can be deleted * List all comments for a repo * Moar data in issue-comments --- issue_comment.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/issue_comment.go b/issue_comment.go index 06f1f3b..17d0262 100644 --- a/issue_comment.go +++ b/issue_comment.go @@ -13,11 +13,14 @@ import ( // Comment represents a comment in commit and issue page. type Comment struct { - ID int64 `json:"id"` - Poster *User `json:"user"` - Body string `json:"body"` - Created time.Time `json:"created_at"` - Updated time.Time `json:"updated_at"` + ID int64 `json:"id"` + HTMLURL string `json:"html_url"` + PRURL string `json:"pull_request_url"` + IssueURL string `json:"issue_url"` + Poster *User `json:"user"` + Body string `json:"body"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` } // ListIssueComments list comments on an issue. @@ -26,6 +29,12 @@ func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment, return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), nil, nil, &comments) } +// ListRepoIssueComments list comments for a given repo. +func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) { + comments := make([]*Comment, 0, 10) + return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments) +} + // CreateIssueCommentOption is option when creating an issue comment. type CreateIssueCommentOption struct { Body string `json:"body" binding:"Required"` @@ -55,3 +64,9 @@ func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, op comment := new(Comment) return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), jsonHeader, bytes.NewReader(body), comment) } + +// DeleteIssueComment deletes an issue comment. +func (c *Client) DeleteIssueComment(owner, repo string, index, commentID int64) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), nil, nil) + return err +} From 3693f6a1a71302d146590845e35fc7fd530aae4e Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 21 Dec 2016 01:16:57 -0500 Subject: [PATCH 05/18] Minor update for PR #48 --- gogs.go | 2 +- issue_comment.go | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/gogs.go b/gogs.go index 389439b..814829b 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.12.3" + return "0.12.4" } // Client represents a Gogs API client. diff --git a/issue_comment.go b/issue_comment.go index 17d0262..246af0d 100644 --- a/issue_comment.go +++ b/issue_comment.go @@ -13,14 +13,12 @@ import ( // Comment represents a comment in commit and issue page. 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"` - Body string `json:"body"` - Created time.Time `json:"created_at"` - Updated time.Time `json:"updated_at"` + ID int64 `json:"id"` + HTMLURL string `json:"html_url"` + Poster *User `json:"user"` + Body string `json:"body"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` } // ListIssueComments list comments on an issue. From 98046bb98061fc6baa5bb86359af0b7c300d384a Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Wed, 21 Dec 2016 04:01:37 -0500 Subject: [PATCH 06/18] Backward compatibility (username vs. login) Reintroduce the username field for user object on JSON marshal to fix backward compatibility. Fixes Drone 0.4 compatibility issues. --- gogs.go | 2 +- user.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gogs.go b/gogs.go index 814829b..d98062e 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.12.4" + return "0.12.5" } // Client represents a Gogs API client. diff --git a/user.go b/user.go index 564a3fb..b385b04 100644 --- a/user.go +++ b/user.go @@ -5,6 +5,7 @@ package gogs import ( + "encoding/json" "fmt" ) @@ -17,6 +18,16 @@ type User struct { AvatarUrl string `json:"avatar_url"` } +// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility +func (u User) MarshalJSON() ([]byte, error) { + // Re-declaring User to avoid recursion + type shadow User + return json.Marshal(struct { + shadow + CompatUserName string `json:"username"` + }{shadow(u), u.UserName}) +} + func (c *Client) GetUserInfo(user string) (*User, error) { u := new(User) err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s", user), nil, nil, u) From 89ff140a38c057e71a1012af6d666fbc037ba606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Tue, 14 Feb 2017 03:02:40 +0100 Subject: [PATCH 07/18] More Repo Collaborator Endpoints (#51) --- repo_collaborator.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/repo_collaborator.go b/repo_collaborator.go index 2a0052d..c382bc7 100644 --- a/repo_collaborator.go +++ b/repo_collaborator.go @@ -10,10 +10,20 @@ import ( "fmt" ) +type Collaborator struct { + *User + Permissions Permission `json:"permissions"` +} + type AddCollaboratorOption struct { Permission *string `json:"permission"` } +func (c *Client) ListCollaborator(user, repo string) ([]*Collaborator, error) { + collabs := make([]*Collaborator, 0, 10) + return collabs, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/collaborators", user, repo), nil, nil, &collabs) +} + func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollaboratorOption) error { body, err := json.Marshal(&opt) if err != nil { @@ -22,3 +32,13 @@ func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollabo _, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, bytes.NewReader(body)) return err } + +func (c *Client) DeleteCollaborator(user, repo, collaborator string) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, nil) + return err +} + +func (c *Client) IsCollaborator(user, repo, collaborator string) error { + _, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, nil) + return err +} From ccf992cbc258d48ece5a2214e8714c4c623f4308 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 24 Feb 2017 01:14:34 -0500 Subject: [PATCH 08/18] repo_hook: update Payloader interface Remove method SetSecret. --- gogs.go | 2 +- repo_hook.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gogs.go b/gogs.go index d98062e..dae81f1 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.12.5" + return "0.12.6" } // Client represents a Gogs API client. diff --git a/repo_hook.go b/repo_hook.go index 7bec411..14ddaff 100644 --- a/repo_hook.go +++ b/repo_hook.go @@ -70,7 +70,6 @@ func (c *Client) DeleteRepoHook(user, repo string, id int64) error { } type Payloader interface { - SetSecret(string) JSONPayload() ([]byte, error) } From f12fbacb5495120dc62dae7cfdf140d39bf6f715 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 24 Feb 2017 01:16:35 -0500 Subject: [PATCH 09/18] repo_hook: update Payloader implementations --- repo_hook.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/repo_hook.go b/repo_hook.go index 14ddaff..6597be5 100644 --- a/repo_hook.go +++ b/repo_hook.go @@ -103,17 +103,12 @@ var ( // \/ \/ \/ \/ type CreatePayload struct { - Secret string `json:"secret"` Ref string `json:"ref"` RefType string `json:"ref_type"` Repo *Repository `json:"repository"` Sender *User `json:"sender"` } -func (p *CreatePayload) SetSecret(secret string) { - p.Secret = secret -} - func (p *CreatePayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") } @@ -147,7 +142,6 @@ func ParseCreateHook(raw []byte) (*CreatePayload, error) { // PushPayload represents a payload information of push event. type PushPayload struct { - Secret string `json:"secret"` Ref string `json:"ref"` Before string `json:"before"` After string `json:"after"` @@ -158,10 +152,6 @@ type PushPayload struct { Sender *User `json:"sender"` } -func (p *PushPayload) SetSecret(secret string) { - p.Secret = secret -} - func (p *PushPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") } @@ -226,7 +216,6 @@ type ChangesPayload struct { // PullRequestPayload represents a payload information of pull request event. type PullRequestPayload struct { - Secret string `json:"secret"` Action HookIssueAction `json:"action"` Index int64 `json:"number"` Changes *ChangesPayload `json:"changes,omitempty"` @@ -235,10 +224,6 @@ type PullRequestPayload struct { Sender *User `json:"sender"` } -func (p *PullRequestPayload) SetSecret(secret string) { - p.Secret = secret -} - func (p *PullRequestPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") } From ba630f557c8349952183305373fa89b155202bac Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 24 Feb 2017 15:25:47 -0500 Subject: [PATCH 10/18] repo_hook: add DeletePayload --- gogs.go | 2 +- repo_hook.go | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/gogs.go b/gogs.go index dae81f1..98421cb 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.12.6" + return "0.12.7" } // Client represents a Gogs API client. diff --git a/repo_hook.go b/repo_hook.go index 6597be5..49c4a5f 100644 --- a/repo_hook.go +++ b/repo_hook.go @@ -91,6 +91,7 @@ type PayloadCommit struct { var ( _ Payloader = &CreatePayload{} + _ Payloader = &DeletePayload{} _ Payloader = &PushPayload{} _ Payloader = &PullRequestPayload{} ) @@ -103,10 +104,11 @@ var ( // \/ \/ \/ \/ type CreatePayload struct { - Ref string `json:"ref"` - RefType string `json:"ref_type"` - Repo *Repository `json:"repository"` - Sender *User `json:"sender"` + Ref string `json:"ref"` + RefType string `json:"ref_type"` + DefaultBranch string `json:"default_branch"` + Repo *Repository `json:"repository"` + Sender *User `json:"sender"` } func (p *CreatePayload) JSONPayload() ([]byte, error) { @@ -133,6 +135,31 @@ func ParseCreateHook(raw []byte) (*CreatePayload, error) { return hook, nil } +// ________ .__ __ +// \______ \ ____ | | _____/ |_ ____ +// | | \_/ __ \| | _/ __ \ __\/ __ \ +// | ` \ ___/| |_\ ___/| | \ ___/ +// /_______ /\___ >____/\___ >__| \___ > +// \/ \/ \/ \/ + +type PusherType string + +const ( + PUSHER_TYPE_USER PusherType = "user" +) + +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"` +} + +func (p *DeletePayload) JSONPayload() ([]byte, error) { + return json.MarshalIndent(p, "", " ") +} + // __________ .__ // \______ \__ __ _____| |__ // | ___/ | \/ ___/ | \ From 264a3d5bc98e108f17cc055338dbf4b94faf0d21 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 25 Feb 2017 03:33:02 -0500 Subject: [PATCH 11/18] repo_hook: add ForkPayload --- repo_hook.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/repo_hook.go b/repo_hook.go index 49c4a5f..aa25122 100644 --- a/repo_hook.go +++ b/repo_hook.go @@ -160,6 +160,23 @@ func (p *DeletePayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") } +// ___________ __ +// \_ _____/__________| | __ +// | __)/ _ \_ __ \ |/ / +// | \( <_> ) | \/ < +// \___ / \____/|__| |__|_ \ +// \/ \/ + +type ForkPayload struct { + Forkee *Repository `json:"forkee"` + Repo *Repository `json:"repository"` + Sender *User `json:"sender"` +} + +func (p *ForkPayload) JSONPayload() ([]byte, error) { + return json.MarshalIndent(p, "", " ") +} + // __________ .__ // \______ \__ __ _____| |__ // | ___/ | \/ ___/ | \ From 559fec59f2c88391ba624da5c40f77c49d8c84eb Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 9 Mar 2017 00:00:34 -0500 Subject: [PATCH 12/18] repo_hook: add IssuesPayload --- gogs.go | 2 +- repo_hook.go | 17 ++++++++++++++++- user.go | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gogs.go b/gogs.go index 98421cb..c34d87f 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.12.7" + return "0.12.8" } // Client represents a Gogs API client. diff --git a/repo_hook.go b/repo_hook.go index aa25122..ca142e2 100644 --- a/repo_hook.go +++ b/repo_hook.go @@ -239,6 +239,8 @@ const ( HOOK_ISSUE_UNASSIGNED HookIssueAction = "unassigned" HOOK_ISSUE_LABEL_UPDATED HookIssueAction = "label_updated" HOOK_ISSUE_LABEL_CLEARED HookIssueAction = "label_cleared" + HOOK_ISSUE_MILESTONED HookIssueAction = "milestoned" + HOOK_ISSUE_DEMILESTONED HookIssueAction = "demilestoned" HOOK_ISSUE_SYNCHRONIZED HookIssueAction = "synchronized" ) @@ -251,6 +253,19 @@ type ChangesPayload struct { Body *ChangesFromPayload `json:"body,omitempty"` } +type IssuesPayload struct { + Action HookIssueAction `json:"action"` + Index int64 `json:"number"` + Issue *Issue `json:"issue"` + Changes *ChangesPayload `json:"changes,omitempty"` + Repository *Repository `json:"repository"` + Sender *User `json:"sender"` +} + +func (p *IssuesPayload) JSONPayload() ([]byte, error) { + return json.MarshalIndent(p, "", " ") +} + // __________ .__ .__ __________ __ // \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_ // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\ @@ -262,8 +277,8 @@ type ChangesPayload struct { type PullRequestPayload struct { Action HookIssueAction `json:"action"` Index int64 `json:"number"` - Changes *ChangesPayload `json:"changes,omitempty"` PullRequest *PullRequest `json:"pull_request"` + Changes *ChangesPayload `json:"changes,omitempty"` Repository *Repository `json:"repository"` Sender *User `json:"sender"` } diff --git a/user.go b/user.go index b385b04..3879b1a 100644 --- a/user.go +++ b/user.go @@ -18,12 +18,13 @@ type User struct { AvatarUrl string `json:"avatar_url"` } -// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility +// MarshalJSON implements the json.Marshaler interface for User func (u User) MarshalJSON() ([]byte, error) { // Re-declaring User to avoid recursion type shadow User return json.Marshal(struct { shadow + // LEGACY [Gogs 1.0]: remove field(s) for backward compatibility CompatUserName string `json:"username"` }{shadow(u), u.UserName}) } From 8e438478f71b840fcd0b3e810684ea4f6bf476bb Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 9 Mar 2017 04:10:09 -0500 Subject: [PATCH 13/18] repo_hook: add IssueCommentPayload --- gogs.go | 2 +- repo_hook.go | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gogs.go b/gogs.go index c34d87f..1d40a25 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.12.8" + return "0.12.9" } // Client represents a Gogs API client. diff --git a/repo_hook.go b/repo_hook.go index ca142e2..5dbe9c2 100644 --- a/repo_hook.go +++ b/repo_hook.go @@ -92,7 +92,10 @@ type PayloadCommit struct { var ( _ Payloader = &CreatePayload{} _ Payloader = &DeletePayload{} + _ Payloader = &ForkPayload{} _ Payloader = &PushPayload{} + _ Payloader = &IssuesPayload{} + _ Payloader = &IssueCommentPayload{} _ Payloader = &PullRequestPayload{} ) @@ -266,6 +269,27 @@ func (p *IssuesPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") } +type HookIssueCommentAction string + +const ( + HOOK_ISSUE_COMMENT_CREATED HookIssueCommentAction = "created" + HOOK_ISSUE_COMMENT_EDITED HookIssueCommentAction = "edited" + HOOK_ISSUE_COMMENT_DELETED HookIssueCommentAction = "deleted" +) + +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"` +} + +func (p *IssueCommentPayload) JSONPayload() ([]byte, error) { + return json.MarshalIndent(p, "", " ") +} + // __________ .__ .__ __________ __ // \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_ // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\ From 08824b5ad7408bc38f2b9287c94be2f059c9966a Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 11 Mar 2017 18:40:19 -0500 Subject: [PATCH 14/18] repo_hook: add ReleasePayload --- gogs.go | 2 +- release.go | 22 ++++++++++++++++++++++ repo_hook.go | 27 +++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 release.go diff --git a/gogs.go b/gogs.go index 1d40a25..e691dd6 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.12.9" + return "0.12.10" } // Client represents a Gogs API client. diff --git a/release.go b/release.go new file mode 100644 index 0000000..69c7f3b --- /dev/null +++ b/release.go @@ -0,0 +1,22 @@ +// Copyright 2017 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package gogs + +import ( + "time" +) + +// Release represents a release API object. +type Release struct { + ID int64 `json:"id"` + TagName string `json:"tag_name"` + TargetCommitish string `json:"target_commitish"` + Name string `json:"name"` + Body string `json:"body"` + Draft bool `json:"draft"` + Prerelease bool `json:"prerelease"` + Author *User `json:"author"` + Created time.Time `json:"created_at"` +} diff --git a/repo_hook.go b/repo_hook.go index 5dbe9c2..1ea7546 100644 --- a/repo_hook.go +++ b/repo_hook.go @@ -256,6 +256,7 @@ type ChangesPayload struct { Body *ChangesFromPayload `json:"body,omitempty"` } +// IssuesPayload represents a payload information of issues event. type IssuesPayload struct { Action HookIssueAction `json:"action"` Index int64 `json:"number"` @@ -277,6 +278,7 @@ const ( HOOK_ISSUE_COMMENT_DELETED HookIssueCommentAction = "deleted" ) +// IssueCommentPayload represents a payload information of issue comment event. type IssueCommentPayload struct { Action HookIssueCommentAction `json:"action"` Issue *Issue `json:"issue"` @@ -310,3 +312,28 @@ type PullRequestPayload struct { func (p *PullRequestPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") } + +// __________ .__ +// \______ \ ____ | | ____ _____ ______ ____ +// | _// __ \| | _/ __ \\__ \ / ___// __ \ +// | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/ +// |____|_ /\___ >____/\___ >____ /____ >\___ > +// \/ \/ \/ \/ \/ \/ + +type HookReleaseAction string + +const ( + HOOK_RELEASE_PUBLISHED HookReleaseAction = "published" +) + +// 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"` +} + +func (p *ReleasePayload) JSONPayload() ([]byte, error) { + return json.MarshalIndent(p, "", " ") +} From 6422399bb531fae9500b29b5d8bfe23aa0ce6beb Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 16 Mar 2017 17:31:09 -0400 Subject: [PATCH 15/18] repo_hook: add file status to PayloadCommit --- gogs.go | 2 +- repo_hook.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gogs.go b/gogs.go index e691dd6..2869e6c 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.12.10" + return "0.12.11" } // Client represents a Gogs API client. diff --git a/repo_hook.go b/repo_hook.go index 1ea7546..3d06b9f 100644 --- a/repo_hook.go +++ b/repo_hook.go @@ -86,7 +86,12 @@ type PayloadCommit struct { URL string `json:"url"` Author *PayloadUser `json:"author"` Committer *PayloadUser `json:"committer"` - Timestamp time.Time `json:"timestamp"` + + Added []string `json:"added"` + Removed []string `json:"removed"` + Modified []string `json:"modified"` + + Timestamp time.Time `json:"timestamp"` } var ( From 9447dded395900409c1d3ad641a2d72502b46282 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 7 Apr 2017 18:14:43 -0400 Subject: [PATCH 16/18] repo: add Repository.Mirror field --- gogs.go | 2 +- repo.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gogs.go b/gogs.go index 2869e6c..1c81d16 100644 --- a/gogs.go +++ b/gogs.go @@ -14,7 +14,7 @@ import ( ) func Version() string { - return "0.12.11" + return "0.12.12" } // Client represents a Gogs API client. diff --git a/repo.go b/repo.go index f3b393c..f89aca5 100644 --- a/repo.go +++ b/repo.go @@ -27,6 +27,7 @@ type Repository struct { Description string `json:"description"` Private bool `json:"private"` Fork bool `json:"fork"` + Mirror bool `json:"mirror"` HTMLURL string `json:"html_url"` SSHURL string `json:"ssh_url"` CloneURL string `json:"clone_url"` From 66b7d300c3f5e3dfcbe4ae2cb3f718d05b5608b8 Mon Sep 17 00:00:00 2001 From: Guyzmo Date: Thu, 4 May 2017 14:45:20 +0200 Subject: [PATCH 17/18] Exposes in API the Repo entity's Size and Isempty properties Signed-off-by: Guyzmo --- repo.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repo.go b/repo.go index f89aca5..6d61410 100644 --- a/repo.go +++ b/repo.go @@ -27,6 +27,8 @@ type Repository struct { Description string `json:"description"` Private bool `json:"private"` Fork bool `json:"fork"` + Empty bool `json:"empty"` + Size int `json:"size"` Mirror bool `json:"mirror"` HTMLURL string `json:"html_url"` SSHURL string `json:"ssh_url"` From 932264d518bee6043b22e4c9cc245a2479d610f5 Mon Sep 17 00:00:00 2001 From: Guyzmo Date: Fri, 5 May 2017 21:04:49 +0200 Subject: [PATCH 18/18] Added ForkID property to the repo API Signed-off-by: Guyzmo --- repo.go | 1 + 1 file changed, 1 insertion(+) diff --git a/repo.go b/repo.go index 6d61410..dc26d6c 100644 --- a/repo.go +++ b/repo.go @@ -27,6 +27,7 @@ type Repository struct { Description string `json:"description"` Private bool `json:"private"` Fork bool `json:"fork"` + ForkID int64 `json:"parent_id"` Empty bool `json:"empty"` Size int `json:"size"` Mirror bool `json:"mirror"`