diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-11-24 15:04:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-24 15:04:31 +0800 |
commit | 3917ed45de063b4e8868610c82d8172020d572fd (patch) | |
tree | 052b7651cbb64ae30f92efe87441ad1d4fa2d922 /routers/api/v1/repo | |
parent | 3a3782bb7fed768c1e832ff4c0a77f2f5281ed05 (diff) | |
download | gitea-3917ed45de063b4e8868610c82d8172020d572fd.tar.gz gitea-3917ed45de063b4e8868610c82d8172020d572fd.zip |
golint fixed for routers (#208)
Diffstat (limited to 'routers/api/v1/repo')
-rw-r--r-- | routers/api/v1/repo/branch.go | 6 | ||||
-rw-r--r-- | routers/api/v1/repo/collaborators.go | 1 | ||||
-rw-r--r-- | routers/api/v1/repo/file.go | 7 | ||||
-rw-r--r-- | routers/api/v1/repo/hook.go | 10 | ||||
-rw-r--r-- | routers/api/v1/repo/issue.go | 4 | ||||
-rw-r--r-- | routers/api/v1/repo/issue_comment.go | 4 | ||||
-rw-r--r-- | routers/api/v1/repo/issue_label.go | 5 | ||||
-rw-r--r-- | routers/api/v1/repo/key.go | 14 | ||||
-rw-r--r-- | routers/api/v1/repo/label.go | 5 | ||||
-rw-r--r-- | routers/api/v1/repo/milestone.go | 5 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 20 |
11 files changed, 64 insertions, 17 deletions
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index 39215ed462..3c73ae62c2 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -11,7 +11,8 @@ import ( "code.gitea.io/gitea/routers/api/v1/convert" ) -// https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch +// GetBranch get a branch of a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch func GetBranch(ctx *context.APIContext) { branch, err := ctx.Repo.Repository.GetBranch(ctx.Params(":branchname")) if err != nil { @@ -28,7 +29,8 @@ func GetBranch(ctx *context.APIContext) { ctx.JSON(200, convert.ToBranch(branch, c)) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches +// ListBranches list all the branches of a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches func ListBranches(ctx *context.APIContext) { branches, err := ctx.Repo.Repository.GetBranches() if err != nil { diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go index 4cad20b60c..a1e8ec6535 100644 --- a/routers/api/v1/repo/collaborators.go +++ b/routers/api/v1/repo/collaborators.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/modules/context" ) +// AddCollaborator add a collaborator of a repository func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) { collaborator, err := models.GetUserByName(ctx.Params(":collaborator")) if err != nil { diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 96948ea459..16a31f96c7 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -12,7 +12,8 @@ import ( "code.gitea.io/gitea/routers/repo" ) -// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content +// GetRawFile get a file by path on a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content func GetRawFile(ctx *context.APIContext) { if !ctx.Repo.HasAccess() { ctx.Status(404) @@ -33,7 +34,8 @@ func GetRawFile(ctx *context.APIContext) { } } -// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive +// GetArchive get archive of a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive func GetArchive(ctx *context.APIContext) { repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame")) gitRepo, err := git.OpenRepository(repoPath) @@ -46,6 +48,7 @@ func GetArchive(ctx *context.APIContext) { repo.Download(ctx.Context) } +// GetEditorconfig get editor config of a repository func GetEditorconfig(ctx *context.APIContext) { ec, err := ctx.Repo.GetEditorconfig() if err != nil { diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 226b50db9f..30e1fad363 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -16,7 +16,8 @@ import ( "code.gitea.io/gitea/routers/api/v1/convert" ) -// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks +// ListHooks list all hooks of a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks func ListHooks(ctx *context.APIContext) { hooks, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID) if err != nil { @@ -31,7 +32,8 @@ func ListHooks(ctx *context.APIContext) { ctx.JSON(200, &apiHooks) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories#create-a-hook +// CreateHook create a hook for a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#create-a-hook func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { if !models.IsValidHookTaskType(form.Type) { ctx.Error(422, "", "Invalid hook type") @@ -97,7 +99,8 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { ctx.JSON(201, convert.ToHook(ctx.Repo.RepoLink, w)) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook +// EditHook modify a hook of a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook func EditHook(ctx *context.APIContext, form api.EditHookOption) { w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) if err != nil { @@ -165,6 +168,7 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) { ctx.JSON(200, convert.ToHook(ctx.Repo.RepoLink, w)) } +// DeleteHook delete a hook of a repository func DeleteHook(ctx *context.APIContext) { if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil { ctx.Error(500, "DeleteWebhookByRepoID", err) diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index c73bf5dbb5..354678c781 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/setting" ) +// ListIssues list the issues of a repository func ListIssues(ctx *context.APIContext) { issues, err := models.Issues(&models.IssuesOptions{ RepoID: ctx.Repo.Repository.ID, @@ -39,6 +40,7 @@ func ListIssues(ctx *context.APIContext) { ctx.JSON(200, &apiIssues) } +// GetIssue get an issue of a repository func GetIssue(ctx *context.APIContext) { issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { @@ -52,6 +54,7 @@ func GetIssue(ctx *context.APIContext) { ctx.JSON(200, issue.APIFormat()) } +// CreateIssue create an issue of a repository func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { issue := &models.Issue{ RepoID: ctx.Repo.Repository.ID, @@ -101,6 +104,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { ctx.JSON(201, issue.APIFormat()) } +// EditIssue modify an issue of a repository func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index cf9a3eae0f..06c7d2b1f5 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -1,6 +1,7 @@ // Copyright 2015 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 repo import ( @@ -12,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/context" ) +// ListIssueComments list all the comments of an issue func ListIssueComments(ctx *context.APIContext) { var since time.Time if len(ctx.Query("since")) > 0 { @@ -38,6 +40,7 @@ func ListIssueComments(ctx *context.APIContext) { ctx.JSON(200, &apiComments) } +// CreateIssueComment create a comment for an issue func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOption) { issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { @@ -54,6 +57,7 @@ func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOpti ctx.JSON(201, comment.APIFormat()) } +// EditIssueComment modify a comment of an issue func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) { comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) if err != nil { diff --git a/routers/api/v1/repo/issue_label.go b/routers/api/v1/repo/issue_label.go index 46d976253a..e91b8e9daf 100644 --- a/routers/api/v1/repo/issue_label.go +++ b/routers/api/v1/repo/issue_label.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/modules/context" ) +// ListIssueLabels list all the labels of an issue func ListIssueLabels(ctx *context.APIContext) { issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { @@ -29,6 +30,7 @@ func ListIssueLabels(ctx *context.APIContext) { ctx.JSON(200, &apiLabels) } +// AddIssueLabels add labels for an issue func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { if !ctx.Repo.IsWriter() { ctx.Status(403) @@ -69,6 +71,7 @@ func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { ctx.JSON(200, &apiLabels) } +// DeleteIssueLabel delete a label for an issue func DeleteIssueLabel(ctx *context.APIContext) { if !ctx.Repo.IsWriter() { ctx.Status(403) @@ -103,6 +106,7 @@ func DeleteIssueLabel(ctx *context.APIContext) { ctx.Status(204) } +// ReplaceIssueLabels replace labels for an issue func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { if !ctx.Repo.IsWriter() { ctx.Status(403) @@ -143,6 +147,7 @@ func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) { ctx.JSON(200, &apiLabels) } +// ClearIssueLabels delete all the labels for an issue func ClearIssueLabels(ctx *context.APIContext) { if !ctx.Repo.IsWriter() { ctx.Status(403) diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go index 4d4240c290..51f080a385 100644 --- a/routers/api/v1/repo/key.go +++ b/routers/api/v1/repo/key.go @@ -19,7 +19,8 @@ func composeDeployKeysAPILink(repoPath string) string { return setting.AppUrl + "api/v1/repos/" + repoPath + "/keys/" } -// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#list-deploy-keys +// ListDeployKeys list all the deploy keys of a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#list-deploy-keys func ListDeployKeys(ctx *context.APIContext) { keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID) if err != nil { @@ -40,7 +41,8 @@ func ListDeployKeys(ctx *context.APIContext) { ctx.JSON(200, &apiKeys) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#get-a-deploy-key +// GetDeployKey get a deploy key by id +// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#get-a-deploy-key func GetDeployKey(ctx *context.APIContext) { key, err := models.GetDeployKeyByID(ctx.ParamsInt64(":id")) if err != nil { @@ -61,6 +63,7 @@ func GetDeployKey(ctx *context.APIContext) { ctx.JSON(200, convert.ToDeployKey(apiLink, key)) } +// HandleCheckKeyStringError handle check key error func HandleCheckKeyStringError(ctx *context.APIContext, err error) { if models.IsErrKeyUnableVerify(err) { ctx.Error(422, "", "Unable to verify key content") @@ -69,6 +72,7 @@ func HandleCheckKeyStringError(ctx *context.APIContext, err error) { } } +// HandleAddKeyError handle add key error func HandleAddKeyError(ctx *context.APIContext, err error) { switch { case models.IsErrKeyAlreadyExist(err): @@ -80,7 +84,8 @@ func HandleAddKeyError(ctx *context.APIContext, err error) { } } -// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#add-a-new-deploy-key +// CreateDeployKey create deploy key for a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#add-a-new-deploy-key func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) { content, err := models.CheckPublicKeyString(form.Key) if err != nil { @@ -99,7 +104,8 @@ func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) { ctx.JSON(201, convert.ToDeployKey(apiLink, key)) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key +// DeleteDeploykey delete deploy key for a repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key func DeleteDeploykey(ctx *context.APIContext) { if err := models.DeleteDeployKey(ctx.User, ctx.ParamsInt64(":id")); err != nil { if models.IsErrKeyAccessDenied(err) { diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go index 009e8d8a0b..383868beda 100644 --- a/routers/api/v1/repo/label.go +++ b/routers/api/v1/repo/label.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/modules/context" ) +// ListLabels list all the labels of a repository func ListLabels(ctx *context.APIContext) { labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID) if err != nil { @@ -25,6 +26,7 @@ func ListLabels(ctx *context.APIContext) { ctx.JSON(200, &apiLabels) } +// GetLabel get label by repository and label id func GetLabel(ctx *context.APIContext) { label, err := models.GetLabelInRepoByID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) if err != nil { @@ -39,6 +41,7 @@ func GetLabel(ctx *context.APIContext) { ctx.JSON(200, label.APIFormat()) } +// CreateLabel create a label for a repository func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) { if !ctx.Repo.IsWriter() { ctx.Status(403) @@ -57,6 +60,7 @@ func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) { ctx.JSON(201, label.APIFormat()) } +// EditLabel modify a label for a repository func EditLabel(ctx *context.APIContext, form api.EditLabelOption) { if !ctx.Repo.IsWriter() { ctx.Status(403) @@ -86,6 +90,7 @@ func EditLabel(ctx *context.APIContext, form api.EditLabelOption) { ctx.JSON(200, label.APIFormat()) } +// DeleteLabel delete a label for a repository func DeleteLabel(ctx *context.APIContext) { if !ctx.Repo.IsWriter() { ctx.Status(403) diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go index 2c6a93f826..ef32ed8989 100644 --- a/routers/api/v1/repo/milestone.go +++ b/routers/api/v1/repo/milestone.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/context" ) +// ListMilestones list all the milestones for a repository func ListMilestones(ctx *context.APIContext) { milestones, err := models.GetMilestonesByRepoID(ctx.Repo.Repository.ID) if err != nil { @@ -27,6 +28,7 @@ func ListMilestones(ctx *context.APIContext) { ctx.JSON(200, &apiMilestones) } +// GetMilestone get a milestone for a repository func GetMilestone(ctx *context.APIContext) { milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) if err != nil { @@ -40,6 +42,7 @@ func GetMilestone(ctx *context.APIContext) { ctx.JSON(200, milestone.APIFormat()) } +// CreateMilestone create a milestone for a repository func CreateMilestone(ctx *context.APIContext, form api.CreateMilestoneOption) { if form.Deadline == nil { defaultDeadline, _ := time.ParseInLocation("2006-01-02", "9999-12-31", time.Local) @@ -60,6 +63,7 @@ func CreateMilestone(ctx *context.APIContext, form api.CreateMilestoneOption) { ctx.JSON(201, milestone.APIFormat()) } +// EditMilestone modify a milestone for a repository func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) { milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) if err != nil { @@ -88,6 +92,7 @@ func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) { ctx.JSON(200, milestone.APIFormat()) } +// DeleteMilestone delete a milestone for a repository func DeleteMilestone(ctx *context.APIContext) { if err := models.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil { ctx.Error(500, "DeleteMilestoneByRepoID", err) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 4353fb74ea..6ae513db16 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -17,7 +17,8 @@ import ( "code.gitea.io/gitea/routers/api/v1/convert" ) -// https://github.com/gogits/go-gogs-client/wiki/Repositories#search-repositories +// Search repositories via options +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#search-repositories func Search(ctx *context.APIContext) { opts := &models.SearchRepoOptions{ Keyword: path.Base(ctx.Query("q")), @@ -76,7 +77,8 @@ func Search(ctx *context.APIContext) { }) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-your-repositories +// ListMyRepos list all my repositories +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-your-repositories func ListMyRepos(ctx *context.APIContext) { ownRepos, err := models.GetUserRepositories(ctx.User.ID, true, 1, ctx.User.NumRepos) if err != nil { @@ -109,6 +111,7 @@ func ListMyRepos(ctx *context.APIContext) { ctx.JSON(200, &repos) } +// CreateUserRepo create a repository for a user func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateRepoOption) { repo, err := models.CreateRepository(owner, models.CreateRepoOptions{ Name: opt.Name, @@ -138,7 +141,8 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR ctx.JSON(201, repo.APIFormat(&api.Permission{true, true, true})) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories#create +// Create create one repository of mine +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#create func Create(ctx *context.APIContext, opt api.CreateRepoOption) { // Shouldn't reach this condition, but just in case. if ctx.User.IsOrganization() { @@ -148,6 +152,7 @@ func Create(ctx *context.APIContext, opt api.CreateRepoOption) { CreateUserRepo(ctx, ctx.User, opt) } +// CreateOrgRepo create one repository of the organization func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) { org, err := models.GetOrgByName(ctx.Params(":org")) if err != nil { @@ -166,7 +171,8 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) { CreateUserRepo(ctx, org, opt) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories#migrate +// Migrate migrate remote git repository to gitea +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#migrate func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { ctxUser := ctx.User // Not equal means context user is an organization, @@ -238,13 +244,15 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { ctx.JSON(201, repo.APIFormat(&api.Permission{true, true, true})) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories#get +// Get get one repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#get func Get(ctx *context.APIContext) { repo := ctx.Repo.Repository ctx.JSON(200, repo.APIFormat(&api.Permission{true, true, true})) } -// https://github.com/gogits/go-gogs-client/wiki/Repositories#delete +// Delete delete one repository +// see https://github.com/gogits/go-gogs-client/wiki/Repositories#delete func Delete(ctx *context.APIContext) { owner := ctx.Repo.Owner repo := ctx.Repo.Repository |