Skip to content

Commit 3917ed4

Browse files
authored
golint fixed for routers (#208)
1 parent 3a3782b commit 3917ed4

35 files changed

+354
-155
lines changed

routers/api/v1/admin/org.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import (
1313
"code.gitea.io/gitea/routers/api/v1/user"
1414
)
1515

16-
// https://github.com/gogits/go-gogs-client/wiki/Administration-Organizations#create-a-new-organization
16+
// CreateOrg api for create organization
17+
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Organizations#create-a-new-organization
1718
func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) {
1819
u := user.GetUserByParams(ctx)
1920
if ctx.Written() {

routers/api/v1/admin/org_repo.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"code.gitea.io/gitea/modules/context"
1010
)
1111

12+
// GetRepositoryByParams api for getting repository by orgnizition ID and repo name
1213
func GetRepositoryByParams(ctx *context.APIContext) *models.Repository {
1314
repo, err := models.GetRepositoryByName(ctx.Org.Team.OrgID, ctx.Params(":reponame"))
1415
if err != nil {
@@ -22,6 +23,7 @@ func GetRepositoryByParams(ctx *context.APIContext) *models.Repository {
2223
return repo
2324
}
2425

26+
// AddTeamRepository api for adding a repository to a team
2527
func AddTeamRepository(ctx *context.APIContext) {
2628
repo := GetRepositoryByParams(ctx)
2729
if ctx.Written() {
@@ -35,6 +37,7 @@ func AddTeamRepository(ctx *context.APIContext) {
3537
ctx.Status(204)
3638
}
3739

40+
// RemoveTeamRepository api for removing a repository from a team
3841
func RemoveTeamRepository(ctx *context.APIContext) {
3942
repo := GetRepositoryByParams(ctx)
4043
if ctx.Written() {

routers/api/v1/admin/org_team.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"code.gitea.io/gitea/routers/api/v1/user"
1414
)
1515

16+
// CreateTeam api for create a team
1617
func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) {
1718
team := &models.Team{
1819
OrgID: ctx.Org.Organization.ID,
@@ -32,6 +33,7 @@ func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) {
3233
ctx.JSON(201, convert.ToTeam(team))
3334
}
3435

36+
// AddTeamMember api for add a member to a team
3537
func AddTeamMember(ctx *context.APIContext) {
3638
u := user.GetUserByParams(ctx)
3739
if ctx.Written() {
@@ -45,6 +47,7 @@ func AddTeamMember(ctx *context.APIContext) {
4547
ctx.Status(204)
4648
}
4749

50+
// RemoveTeamMember api for remove one member from a team
4851
func RemoveTeamMember(ctx *context.APIContext) {
4952
u := user.GetUserByParams(ctx)
5053
if ctx.Written() {

routers/api/v1/admin/repo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
"code.gitea.io/gitea/routers/api/v1/user"
1313
)
1414

15-
// https://github.com/gogits/go-gogs-client/wiki/Administration-Repositories#create-a-new-repository
15+
// CreateRepo api for creating a repository
16+
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Repositories#create-a-new-repository
1617
func CreateRepo(ctx *context.APIContext, form api.CreateRepoOption) {
1718
owner := user.GetUserByParams(ctx)
1819
if ctx.Written() {

routers/api/v1/admin/user.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func parseLoginSource(ctx *context.APIContext, u *models.User, sourceID int64, l
3434
u.LoginName = loginName
3535
}
3636

37-
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-new-user
37+
// CreateUser api for creating a user
38+
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-new-user
3839
func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
3940
u := &models.User{
4041
Name: form.Username,
@@ -71,7 +72,8 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
7172
ctx.JSON(201, u.APIFormat())
7273
}
7374

74-
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#edit-an-existing-user
75+
// EditUser api for modifying a user's information
76+
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Users#edit-an-existing-user
7577
func EditUser(ctx *context.APIContext, form api.EditUserOption) {
7678
u := user.GetUserByParams(ctx)
7779
if ctx.Written() {
@@ -123,6 +125,7 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) {
123125
ctx.JSON(200, u.APIFormat())
124126
}
125127

128+
// DeleteUser api for deleting a user
126129
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#delete-a-user
127130
func DeleteUser(ctx *context.APIContext) {
128131
u := user.GetUserByParams(ctx)
@@ -144,7 +147,8 @@ func DeleteUser(ctx *context.APIContext) {
144147
ctx.Status(204)
145148
}
146149

147-
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-public-key-for-user
150+
// CreatePublicKey api for creating a public key to a user
151+
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-public-key-for-user
148152
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
149153
u := user.GetUserByParams(ctx)
150154
if ctx.Written() {

routers/api/v1/convert/convert.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import (
99

1010
"github.com/Unknwon/com"
1111

12-
"code.gitea.io/git"
1312
api "code.gitea.io/sdk/gitea"
1413

14+
"code.gitea.io/git"
1515
"code.gitea.io/gitea/models"
1616
)
1717

18+
// ToEmail convert models.EmailAddress to api.Email
1819
func ToEmail(email *models.EmailAddress) *api.Email {
1920
return &api.Email{
2021
Email: email.Email,
@@ -23,13 +24,15 @@ func ToEmail(email *models.EmailAddress) *api.Email {
2324
}
2425
}
2526

27+
// ToBranch convert a commit and branch to an api.Branch
2628
func ToBranch(b *models.Branch, c *git.Commit) *api.Branch {
2729
return &api.Branch{
2830
Name: b.Name,
2931
Commit: ToCommit(c),
3032
}
3133
}
3234

35+
// ToCommit convert a commit to api.PayloadCommit
3336
func ToCommit(c *git.Commit) *api.PayloadCommit {
3437
authorUsername := ""
3538
author, err := models.GetUserByEmail(c.Author.Email)
@@ -59,6 +62,7 @@ func ToCommit(c *git.Commit) *api.PayloadCommit {
5962
}
6063
}
6164

65+
// ToPublicKey convert models.PublicKey to api.PublicKey
6266
func ToPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey {
6367
return &api.PublicKey{
6468
ID: key.ID,
@@ -69,6 +73,7 @@ func ToPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey {
6973
}
7074
}
7175

76+
// ToHook convert models.Webhook to api.Hook
7277
func ToHook(repoLink string, w *models.Webhook) *api.Hook {
7378
config := map[string]string{
7479
"url": w.URL,
@@ -94,6 +99,7 @@ func ToHook(repoLink string, w *models.Webhook) *api.Hook {
9499
}
95100
}
96101

102+
// ToDeployKey convert models.DeployKey to api.DeployKey
97103
func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
98104
return &api.DeployKey{
99105
ID: key.ID,
@@ -105,6 +111,7 @@ func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
105111
}
106112
}
107113

114+
// ToOrganization convert models.User to api.Organization
108115
func ToOrganization(org *models.User) *api.Organization {
109116
return &api.Organization{
110117
ID: org.ID,
@@ -117,6 +124,7 @@ func ToOrganization(org *models.User) *api.Organization {
117124
}
118125
}
119126

127+
// ToTeam convert models.Team to api.Team
120128
func ToTeam(team *models.Team) *api.Team {
121129
return &api.Team{
122130
ID: team.ID,

routers/api/v1/misc/markdown.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
"code.gitea.io/gitea/modules/markdown"
1212
)
1313

14-
// https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-an-arbitrary-markdown-document
14+
// Markdown render markdown document to HTML
15+
// see https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-an-arbitrary-markdown-document
1516
func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
1617
if ctx.HasApiError() {
1718
ctx.Error(422, "", ctx.GetErrMsg())
@@ -31,7 +32,8 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
3132
}
3233
}
3334

34-
// https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-a-markdown-document-in-raw-mode
35+
// MarkdownRaw render raw markdown HTML
36+
// see https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-a-markdown-document-in-raw-mode
3537
func MarkdownRaw(ctx *context.APIContext) {
3638
body, err := ctx.Req.Body().Bytes()
3739
if err != nil {

routers/api/v1/org/org.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ func listUserOrgs(ctx *context.APIContext, u *models.User, all bool) {
2626
ctx.JSON(200, &apiOrgs)
2727
}
2828

29-
// https://github.com/gogits/go-gogs-client/wiki/Organizations#list-your-organizations
29+
// ListMyOrgs list all my orgs
30+
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#list-your-organizations
3031
func ListMyOrgs(ctx *context.APIContext) {
3132
listUserOrgs(ctx, ctx.User, true)
3233
}
3334

34-
// https://github.com/gogits/go-gogs-client/wiki/Organizations#list-user-organizations
35+
// ListUserOrgs list user's orgs
36+
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#list-user-organizations
3537
func ListUserOrgs(ctx *context.APIContext) {
3638
u := user.GetUserByParams(ctx)
3739
if ctx.Written() {
@@ -40,12 +42,14 @@ func ListUserOrgs(ctx *context.APIContext) {
4042
listUserOrgs(ctx, u, false)
4143
}
4244

43-
// https://github.com/gogits/go-gogs-client/wiki/Organizations#get-an-organization
45+
// Get get an organization
46+
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#get-an-organization
4447
func Get(ctx *context.APIContext) {
4548
ctx.JSON(200, convert.ToOrganization(ctx.Org.Organization))
4649
}
4750

48-
// https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization
51+
// Edit change an organization's information
52+
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization
4953
func Edit(ctx *context.APIContext, form api.EditOrgOption) {
5054
org := ctx.Org.Organization
5155
if !org.IsOwnedBy(ctx.User.ID) {

routers/api/v1/org/team.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"code.gitea.io/gitea/routers/api/v1/convert"
1212
)
1313

14+
// ListTeams list all the teams of an organization
1415
func ListTeams(ctx *context.APIContext) {
1516
org := ctx.Org.Organization
1617
if err := org.GetTeams(); err != nil {

routers/api/v1/repo/branch.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
"code.gitea.io/gitea/routers/api/v1/convert"
1212
)
1313

14-
// https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch
14+
// GetBranch get a branch of a repository
15+
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch
1516
func GetBranch(ctx *context.APIContext) {
1617
branch, err := ctx.Repo.Repository.GetBranch(ctx.Params(":branchname"))
1718
if err != nil {
@@ -28,7 +29,8 @@ func GetBranch(ctx *context.APIContext) {
2829
ctx.JSON(200, convert.ToBranch(branch, c))
2930
}
3031

31-
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches
32+
// ListBranches list all the branches of a repository
33+
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches
3234
func ListBranches(ctx *context.APIContext) {
3335
branches, err := ctx.Repo.Repository.GetBranches()
3436
if err != nil {

routers/api/v1/repo/collaborators.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"code.gitea.io/gitea/modules/context"
1212
)
1313

14+
// AddCollaborator add a collaborator of a repository
1415
func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
1516
collaborator, err := models.GetUserByName(ctx.Params(":collaborator"))
1617
if err != nil {

routers/api/v1/repo/file.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
"code.gitea.io/gitea/routers/repo"
1313
)
1414

15-
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content
15+
// GetRawFile get a file by path on a repository
16+
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content
1617
func GetRawFile(ctx *context.APIContext) {
1718
if !ctx.Repo.HasAccess() {
1819
ctx.Status(404)
@@ -33,7 +34,8 @@ func GetRawFile(ctx *context.APIContext) {
3334
}
3435
}
3536

36-
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive
37+
// GetArchive get archive of a repository
38+
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive
3739
func GetArchive(ctx *context.APIContext) {
3840
repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame"))
3941
gitRepo, err := git.OpenRepository(repoPath)
@@ -46,6 +48,7 @@ func GetArchive(ctx *context.APIContext) {
4648
repo.Download(ctx.Context)
4749
}
4850

51+
// GetEditorconfig get editor config of a repository
4952
func GetEditorconfig(ctx *context.APIContext) {
5053
ec, err := ctx.Repo.GetEditorconfig()
5154
if err != nil {

routers/api/v1/repo/hook.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import (
1616
"code.gitea.io/gitea/routers/api/v1/convert"
1717
)
1818

19-
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks
19+
// ListHooks list all hooks of a repository
20+
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks
2021
func ListHooks(ctx *context.APIContext) {
2122
hooks, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID)
2223
if err != nil {
@@ -31,7 +32,8 @@ func ListHooks(ctx *context.APIContext) {
3132
ctx.JSON(200, &apiHooks)
3233
}
3334

34-
// https://github.com/gogits/go-gogs-client/wiki/Repositories#create-a-hook
35+
// CreateHook create a hook for a repository
36+
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#create-a-hook
3537
func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
3638
if !models.IsValidHookTaskType(form.Type) {
3739
ctx.Error(422, "", "Invalid hook type")
@@ -97,7 +99,8 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
9799
ctx.JSON(201, convert.ToHook(ctx.Repo.RepoLink, w))
98100
}
99101

100-
// https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook
102+
// EditHook modify a hook of a repository
103+
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook
101104
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
102105
w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
103106
if err != nil {
@@ -165,6 +168,7 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) {
165168
ctx.JSON(200, convert.ToHook(ctx.Repo.RepoLink, w))
166169
}
167170

171+
// DeleteHook delete a hook of a repository
168172
func DeleteHook(ctx *context.APIContext) {
169173
if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
170174
ctx.Error(500, "DeleteWebhookByRepoID", err)

routers/api/v1/repo/issue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"code.gitea.io/gitea/modules/setting"
1616
)
1717

18+
// ListIssues list the issues of a repository
1819
func ListIssues(ctx *context.APIContext) {
1920
issues, err := models.Issues(&models.IssuesOptions{
2021
RepoID: ctx.Repo.Repository.ID,
@@ -39,6 +40,7 @@ func ListIssues(ctx *context.APIContext) {
3940
ctx.JSON(200, &apiIssues)
4041
}
4142

43+
// GetIssue get an issue of a repository
4244
func GetIssue(ctx *context.APIContext) {
4345
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
4446
if err != nil {
@@ -52,6 +54,7 @@ func GetIssue(ctx *context.APIContext) {
5254
ctx.JSON(200, issue.APIFormat())
5355
}
5456

57+
// CreateIssue create an issue of a repository
5558
func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
5659
issue := &models.Issue{
5760
RepoID: ctx.Repo.Repository.ID,
@@ -101,6 +104,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
101104
ctx.JSON(201, issue.APIFormat())
102105
}
103106

107+
// EditIssue modify an issue of a repository
104108
func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
105109
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
106110
if err != nil {

routers/api/v1/repo/issue_comment.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2015 The Gogs Authors. All rights reserved.
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
4+
45
package repo
56

67
import (
@@ -12,6 +13,7 @@ import (
1213
"code.gitea.io/gitea/modules/context"
1314
)
1415

16+
// ListIssueComments list all the comments of an issue
1517
func ListIssueComments(ctx *context.APIContext) {
1618
var since time.Time
1719
if len(ctx.Query("since")) > 0 {
@@ -38,6 +40,7 @@ func ListIssueComments(ctx *context.APIContext) {
3840
ctx.JSON(200, &apiComments)
3941
}
4042

43+
// CreateIssueComment create a comment for an issue
4144
func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOption) {
4245
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
4346
if err != nil {
@@ -54,6 +57,7 @@ func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOpti
5457
ctx.JSON(201, comment.APIFormat())
5558
}
5659

60+
// EditIssueComment modify a comment of an issue
5761
func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) {
5862
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
5963
if err != nil {

0 commit comments

Comments
 (0)