Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit 156c90f

Browse files
authored
Merge pull request #12 from lunny/go_lint_fix
WIP: fix most of all the lint errors
2 parents 163100b + c9135ef commit 156c90f

23 files changed

+167
-29
lines changed

gitea/admin_org.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111
)
1212

13+
// AdminCreateOrg create an organization
1314
func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error) {
1415
body, err := json.Marshal(&opt)
1516
if err != nil {

gitea/admin_repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111
)
1212

13+
// AdminCreateRepo create a repo
1314
func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, error) {
1415
body, err := json.Marshal(&opt)
1516
if err != nil {

gitea/admin_user.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111
)
1212

13+
// CreateUserOption create user options
1314
type CreateUserOption struct {
1415
SourceID int64 `json:"source_id"`
1516
LoginName string `json:"login_name"`
@@ -20,6 +21,7 @@ type CreateUserOption struct {
2021
SendNotify bool `json:"send_notify"`
2122
}
2223

24+
// AdminCreateUser create a user
2325
func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) {
2426
body, err := json.Marshal(&opt)
2527
if err != nil {
@@ -29,6 +31,7 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) {
2931
return user, c.getParsedResponse("POST", "/admin/users", jsonHeader, bytes.NewReader(body), user)
3032
}
3133

34+
// EditUserOption edit user options
3235
type EditUserOption struct {
3336
SourceID int64 `json:"source_id"`
3437
LoginName string `json:"login_name"`
@@ -44,6 +47,7 @@ type EditUserOption struct {
4447
MaxRepoCreation *int `json:"max_repo_creation"`
4548
}
4649

50+
// AdminEditUser modify user informations
4751
func (c *Client) AdminEditUser(user string, opt EditUserOption) error {
4852
body, err := json.Marshal(&opt)
4953
if err != nil {
@@ -53,11 +57,13 @@ func (c *Client) AdminEditUser(user string, opt EditUserOption) error {
5357
return err
5458
}
5559

60+
// AdminDeleteUser delete one user according name
5661
func (c *Client) AdminDeleteUser(user string) error {
5762
_, err := c.getResponse("DELETE", fmt.Sprintf("/admin/users/%s", user), nil, nil)
5863
return err
5964
}
6065

66+
// AdminCreateUserPublicKey create one user with options
6167
func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) {
6268
body, err := json.Marshal(&opt)
6369
if err != nil {

gitea/gitea.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"strings"
1414
)
1515

16+
// Version return the library version
1617
func Version() string {
1718
return "0.12.3"
1819
}

gitea/issue.go

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,58 @@ import (
1111
"time"
1212
)
1313

14-
type StateType string
14+
// PRStateType issue state type
15+
type PRStateType string
1516

1617
const (
17-
STATE_OPEN StateType = "open"
18-
STATE_CLOSED StateType = "closed"
18+
// PRStateOpen pr is opend
19+
PRStateOpen PRStateType = "open"
20+
// PRStateClosed pr is closed
21+
PRStateClosed PRStateType = "closed"
1922
)
2023

24+
// PullRequestMeta PR info if an issue is a PR
2125
type PullRequestMeta struct {
2226
HasMerged bool `json:"merged"`
2327
Merged *time.Time `json:"merged_at"`
2428
}
2529

30+
// Issue an issue to a repository
2631
type Issue struct {
27-
ID int64 `json:"id"`
28-
Index int64 `json:"number"`
29-
Poster *User `json:"user"`
30-
Title string `json:"title"`
31-
Body string `json:"body"`
32-
Labels []*Label `json:"labels"`
33-
Milestone *Milestone `json:"milestone"`
34-
Assignee *User `json:"assignee"`
35-
State StateType `json:"state"`
36-
Comments int `json:"comments"`
37-
Created time.Time `json:"created_at"`
38-
Updated time.Time `json:"updated_at"`
32+
ID int64 `json:"id"`
33+
Index int64 `json:"number"`
34+
Poster *User `json:"user"`
35+
Title string `json:"title"`
36+
Body string `json:"body"`
37+
Labels []*Label `json:"labels"`
38+
Milestone *Milestone `json:"milestone"`
39+
Assignee *User `json:"assignee"`
40+
State PRStateType `json:"state"`
41+
Comments int `json:"comments"`
42+
Created time.Time `json:"created_at"`
43+
Updated time.Time `json:"updated_at"`
3944

4045
PullRequest *PullRequestMeta `json:"pull_request"`
4146
}
4247

48+
// ListIssueOption list issue options
4349
type ListIssueOption struct {
4450
Page int
4551
}
4652

53+
// ListRepoIssues list one repos' issues
4754
func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Issue, error) {
4855
issues := make([]*Issue, 0, 10)
4956
return issues, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues?page=%d", owner, repo, opt.Page), nil, nil, &issues)
5057
}
5158

59+
// GetIssue get some one issue of repository
5260
func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, error) {
5361
issue := new(Issue)
5462
return issue, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), nil, nil, issue)
5563
}
5664

65+
// CreateIssueOption options to create one issue
5766
type CreateIssueOption struct {
5867
Title string `json:"title" binding:"Required"`
5968
Body string `json:"body"`
@@ -63,6 +72,7 @@ type CreateIssueOption struct {
6372
Closed bool `json:"closed"`
6473
}
6574

75+
// CreateIssue create an issue with options
6676
func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, error) {
6777
body, err := json.Marshal(&opt)
6878
if err != nil {
@@ -73,6 +83,7 @@ func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue,
7383
jsonHeader, bytes.NewReader(body), issue)
7484
}
7585

86+
// EditIssueOption edit issue options
7687
type EditIssueOption struct {
7788
Title string `json:"title"`
7889
Body *string `json:"body"`
@@ -81,6 +92,7 @@ type EditIssueOption struct {
8192
State *string `json:"state"`
8293
}
8394

95+
// EditIssue modify an issue of repository
8496
func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption) (*Issue, error) {
8597
body, err := json.Marshal(&opt)
8698
if err != nil {

gitea/issue_label.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,33 @@ import (
1010
"fmt"
1111
)
1212

13+
// Label a label to an issue or a pr
1314
type Label struct {
1415
ID int64 `json:"id"`
1516
Name string `json:"name"`
1617
Color string `json:"color"`
1718
}
1819

20+
// ListRepoLabels list lables of one reppsitory
1921
func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) {
2022
labels := make([]*Label, 0, 10)
2123
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels)
2224
}
2325

26+
// GetRepoLabel get one label of repository by repo it
27+
// TODO: maybe we need get a label by name
2428
func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) {
2529
label := new(Label)
2630
return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label)
2731
}
2832

33+
// CreateLabelOption create options when one label of repository
2934
type CreateLabelOption struct {
3035
Name string `json:"name" binding:"Required"`
3136
Color string `json:"color" binding:"Required;Size(7)"`
3237
}
3338

39+
// CreateLabel create one label of repository
3440
func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, error) {
3541
body, err := json.Marshal(&opt)
3642
if err != nil {
@@ -41,11 +47,13 @@ func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label,
4147
jsonHeader, bytes.NewReader(body), label)
4248
}
4349

50+
// EditLabelOption edit label options
4451
type EditLabelOption struct {
4552
Name *string `json:"name"`
4653
Color *string `json:"color"`
4754
}
4855

56+
// EditLabel modify one label with options
4957
func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (*Label, error) {
5058
body, err := json.Marshal(&opt)
5159
if err != nil {
@@ -55,43 +63,52 @@ func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (*
5563
return label, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), jsonHeader, bytes.NewReader(body), label)
5664
}
5765

66+
// DeleteLabel delete one label of repository by id
67+
// TODO: maybe we need delete by name
5868
func (c *Client) DeleteLabel(owner, repo string, id int64) error {
5969
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil)
6070
return err
6171
}
6272

73+
// IssueLabelsOption list one issue's labels options
6374
type IssueLabelsOption struct {
6475
Labels []int64 `json:"labels"`
6576
}
6677

78+
// GetIssueLabels get labels of one issue via issue id
6779
func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, error) {
6880
labels := make([]*Label, 0, 5)
6981
return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil, &labels)
7082
}
7183

84+
// AddIssueLabels add one or more labels to one issue
7285
func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) {
7386
body, err := json.Marshal(&opt)
7487
if err != nil {
7588
return nil, err
7689
}
77-
labels := make([]*Label, 0)
90+
var labels []*Label
7891
return labels, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), jsonHeader, bytes.NewReader(body), &labels)
7992
}
8093

94+
// ReplaceIssueLabels replace old labels of issue with new labels
8195
func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) {
8296
body, err := json.Marshal(&opt)
8397
if err != nil {
8498
return nil, err
8599
}
86-
labels := make([]*Label, 0)
100+
var labels []*Label
87101
return labels, c.getParsedResponse("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), jsonHeader, bytes.NewReader(body), &labels)
88102
}
89103

104+
// DeleteIssueLabel delete one label of one issue by issue id and label id
105+
// TODO: maybe we need delete by label name and issue id
90106
func (c *Client) DeleteIssueLabel(owner, repo string, index, label int64) error {
91107
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels/%d", owner, repo, index, label), nil, nil)
92108
return err
93109
}
94110

111+
// ClearIssueLabels delete all the labels of one issue.
95112
func (c *Client) ClearIssueLabels(owner, repo string, index int64) error {
96113
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil)
97114
return err

gitea/issue_milestone.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212
)
1313

14+
// Milestone milestone is a collection of issues on one repository
1415
type Milestone struct {
1516
ID int64 `json:"id"`
1617
Title string `json:"title"`
@@ -22,22 +23,26 @@ type Milestone struct {
2223
Deadline *time.Time `json:"due_on"`
2324
}
2425

26+
// ListRepoMilestones list all the milestones of one repository
2527
func (c *Client) ListRepoMilestones(owner, repo string) ([]*Milestone, error) {
2628
milestones := make([]*Milestone, 0, 10)
2729
return milestones, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), nil, nil, &milestones)
2830
}
2931

32+
// GetMilestone get one milestone by repo name and milestone id
3033
func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error) {
3134
milestone := new(Milestone)
3235
return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone)
3336
}
3437

38+
// CreateMilestoneOption options when creating milestone
3539
type CreateMilestoneOption struct {
3640
Title string `json:"title"`
3741
Description string `json:"description"`
3842
Deadline *time.Time `json:"due_on"`
3943
}
4044

45+
// CreateMilestone create one milestone with options
4146
func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) (*Milestone, error) {
4247
body, err := json.Marshal(&opt)
4348
if err != nil {
@@ -47,13 +52,15 @@ func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption)
4752
return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone)
4853
}
4954

55+
// EditMilestoneOption options when modify milestone
5056
type EditMilestoneOption struct {
5157
Title string `json:"title"`
5258
Description *string `json:"description"`
5359
State *string `json:"state"`
5460
Deadline *time.Time `json:"due_on"`
5561
}
5662

63+
// EditMilestone modify milestone with options
5764
func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOption) (*Milestone, error) {
5865
body, err := json.Marshal(&opt)
5966
if err != nil {
@@ -63,6 +70,7 @@ func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOp
6370
return milestone, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), jsonHeader, bytes.NewReader(body), milestone)
6471
}
6572

73+
// DeleteMilestone delete one milestone by milestone id
6674
func (c *Client) DeleteMilestone(owner, repo string, id int64) error {
6775
_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil)
6876
return err

gitea/miscellaneous.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package gitea
66

7+
// MarkdownOption markdown options
78
type MarkdownOption struct {
89
Text string
910
Mode string

gitea/org.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,36 @@ import (
1010
"fmt"
1111
)
1212

13+
// Organization a group of some repositories, users and teams
1314
type Organization struct {
1415
ID int64 `json:"id"`
1516
UserName string `json:"username"`
1617
FullName string `json:"full_name"`
17-
AvatarUrl string `json:"avatar_url"`
18+
AvatarURL string `json:"avatar_url"`
1819
Description string `json:"description"`
1920
Website string `json:"website"`
2021
Location string `json:"location"`
2122
}
2223

24+
// ListMyOrgs list all of current user's organizations
2325
func (c *Client) ListMyOrgs() ([]*Organization, error) {
2426
orgs := make([]*Organization, 0, 5)
2527
return orgs, c.getParsedResponse("GET", "/user/orgs", nil, nil, &orgs)
2628
}
2729

30+
// ListUserOrgs list all of some user's organizations
2831
func (c *Client) ListUserOrgs(user string) ([]*Organization, error) {
2932
orgs := make([]*Organization, 0, 5)
3033
return orgs, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/orgs", user), nil, nil, &orgs)
3134
}
3235

36+
// GetOrg get one organization by name
3337
func (c *Client) GetOrg(orgname string) (*Organization, error) {
3438
org := new(Organization)
3539
return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org)
3640
}
3741

42+
// CreateOrgOption create one organization options
3843
type CreateOrgOption struct {
3944
UserName string `json:"username" binding:"Required"`
4045
FullName string `json:"full_name"`
@@ -43,13 +48,15 @@ type CreateOrgOption struct {
4348
Location string `json:"location"`
4449
}
4550

51+
// EditOrgOption edit one organization options
4652
type EditOrgOption struct {
4753
FullName string `json:"full_name"`
4854
Description string `json:"description"`
4955
Website string `json:"website"`
5056
Location string `json:"location"`
5157
}
5258

59+
// EditOrg modify one organization via options
5360
func (c *Client) EditOrg(orgname string, opt EditOrgOption) error {
5461
body, err := json.Marshal(&opt)
5562
if err != nil {

0 commit comments

Comments
 (0)