summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-01-20 18:46:10 +0100
committerGitHub <noreply@github.com>2022-01-20 18:46:10 +0100
commit54e9ee37a7a301dbe74d46fd3c87712e6120e9bf (patch)
tree1be12fb072625c1b896b9d72f7912b018aad502b /routers
parent1d98d205f5825f40110e6628b61a97c91ac7f72d (diff)
downloadgitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.tar.gz
gitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.zip
format with gofumpt (#18184)
* gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/admin/org.go2
-rw-r--r--routers/api/v1/admin/user.go2
-rw-r--r--routers/api/v1/api.go12
-rw-r--r--routers/api/v1/misc/markdown_test.go10
-rw-r--r--routers/api/v1/org/hook.go4
-rw-r--r--routers/api/v1/org/org.go4
-rw-r--r--routers/api/v1/repo/branch.go6
-rw-r--r--routers/api/v1/repo/fork.go2
-rw-r--r--routers/api/v1/repo/issue.go2
-rw-r--r--routers/api/v1/repo/issue_reaction.go4
-rw-r--r--routers/api/v1/repo/issue_subscription.go4
-rw-r--r--routers/api/v1/repo/issue_tracked_time.go4
-rw-r--r--routers/api/v1/repo/migrate.go4
-rw-r--r--routers/api/v1/repo/milestone.go2
-rw-r--r--routers/api/v1/repo/pull.go1
-rw-r--r--routers/api/v1/repo/release_attachment.go2
-rw-r--r--routers/api/v1/repo/repo.go6
-rw-r--r--routers/api/v1/repo/repo_test.go4
-rw-r--r--routers/api/v1/repo/status.go2
-rw-r--r--routers/api/v1/repo/wiki.go5
-rw-r--r--routers/api/v1/user/gpg_key.go10
-rw-r--r--routers/api/v1/user/watch.go1
-rw-r--r--routers/api/v1/utils/git.go4
-rw-r--r--routers/common/middleware.go2
-rw-r--r--routers/install/install.go8
-rw-r--r--routers/install/routes.go4
-rw-r--r--routers/private/internal.go6
-rw-r--r--routers/private/manager_unix.go1
-rw-r--r--routers/private/restore_repo.go2
-rw-r--r--routers/web/admin/admin.go2
-rw-r--r--routers/web/admin/admin_test.go2
-rw-r--r--routers/web/admin/emails.go5
-rw-r--r--routers/web/admin/users_test.go1
-rw-r--r--routers/web/auth/auth.go6
-rw-r--r--routers/web/auth/linkaccount.go4
-rw-r--r--routers/web/auth/oauth.go1
-rw-r--r--routers/web/auth/openid.go4
-rw-r--r--routers/web/auth/webauthn.go2
-rw-r--r--routers/web/base.go10
-rw-r--r--routers/web/explore/code.go4
-rw-r--r--routers/web/explore/user.go4
-rw-r--r--routers/web/org/home.go2
-rw-r--r--routers/web/org/members.go2
-rw-r--r--routers/web/org/setting.go3
-rw-r--r--routers/web/repo/attachment.go10
-rw-r--r--routers/web/repo/blame.go6
-rw-r--r--routers/web/repo/branch.go2
-rw-r--r--routers/web/repo/compare.go9
-rw-r--r--routers/web/repo/download.go2
-rw-r--r--routers/web/repo/editor_test.go2
-rw-r--r--routers/web/repo/http.go5
-rw-r--r--routers/web/repo/issue.go32
-rw-r--r--routers/web/repo/issue_content_history.go8
-rw-r--r--routers/web/repo/issue_lock.go1
-rw-r--r--routers/web/repo/issue_test.go4
-rw-r--r--routers/web/repo/lfs.go4
-rw-r--r--routers/web/repo/migrate.go2
-rw-r--r--routers/web/repo/projects.go1
-rw-r--r--routers/web/repo/pull.go23
-rw-r--r--routers/web/repo/release.go2
-rw-r--r--routers/web/repo/repo.go6
-rw-r--r--routers/web/repo/settings_test.go5
-rw-r--r--routers/web/repo/topic.go4
-rw-r--r--routers/web/repo/view.go7
-rw-r--r--routers/web/repo/wiki.go8
-rw-r--r--routers/web/repo/wiki_test.go6
-rw-r--r--routers/web/user/home.go18
-rw-r--r--routers/web/user/profile.go3
-rw-r--r--routers/web/user/setting/account_test.go6
-rw-r--r--routers/web/user/setting/keys.go1
-rw-r--r--routers/web/user/setting/profile.go1
-rw-r--r--routers/web/web.go9
72 files changed, 160 insertions, 199 deletions
diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go
index bdfe87fd4e..aaa27afb9e 100644
--- a/routers/api/v1/admin/org.go
+++ b/routers/api/v1/admin/org.go
@@ -82,7 +82,7 @@ func CreateOrg(ctx *context.APIContext) {
ctx.JSON(http.StatusCreated, convert.ToOrganization(org))
}
-//GetAllOrgs API for getting information of all the organizations
+// GetAllOrgs API for getting information of all the organizations
func GetAllOrgs(ctx *context.APIContext) {
// swagger:operation GET /admin/orgs admin adminGetAllOrgs
// ---
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go
index e95ab33d77..0ecebad5d7 100644
--- a/routers/api/v1/admin/user.go
+++ b/routers/api/v1/admin/user.go
@@ -403,7 +403,7 @@ func DeleteUserPublicKey(ctx *context.APIContext) {
ctx.Status(http.StatusNoContent)
}
-//GetAllUsers API for getting information of all the users
+// GetAllUsers API for getting information of all the users
func GetAllUsers(ctx *context.APIContext) {
// swagger:operation GET /admin/users admin adminGetAllUsers
// ---
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 7a723a138a..df00a852f2 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -333,7 +333,7 @@ func reqTeamMembership() func(ctx *context.APIContext) {
return
}
- var orgID = ctx.Org.Team.OrgID
+ orgID := ctx.Org.Team.OrgID
isOwner, err := models.IsOrganizationOwner(orgID, ctx.User.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "IsOrganizationOwner", err)
@@ -545,12 +545,12 @@ func mustNotBeArchived(ctx *context.APIContext) {
// bind binding an obj to a func(ctx *context.APIContext)
func bind(obj interface{}) http.HandlerFunc {
- var tp = reflect.TypeOf(obj)
+ tp := reflect.TypeOf(obj)
for tp.Kind() == reflect.Ptr {
tp = tp.Elem()
}
return web.Wrap(func(ctx *context.APIContext) {
- var theObj = reflect.New(tp).Interface() // create a new form obj for every request but not use obj directly
+ theObj := reflect.New(tp).Interface() // create a new form obj for every request but not use obj directly
errs := binding.Bind(ctx.Req, theObj)
if len(errs) > 0 {
ctx.Error(http.StatusUnprocessableEntity, "validationError", fmt.Sprintf("%s: %s", errs[0].FieldNames, errs[0].Error()))
@@ -562,16 +562,16 @@ func bind(obj interface{}) http.HandlerFunc {
// Routes registers all v1 APIs routes to web application.
func Routes(sessioner func(http.Handler) http.Handler) *web.Route {
- var m = web.NewRoute()
+ m := web.NewRoute()
m.Use(sessioner)
m.Use(securityHeaders())
if setting.CORSConfig.Enabled {
m.Use(cors.Handler(cors.Options{
- //Scheme: setting.CORSConfig.Scheme, // FIXME: the cors middleware needs scheme option
+ // Scheme: setting.CORSConfig.Scheme, // FIXME: the cors middleware needs scheme option
AllowedOrigins: setting.CORSConfig.AllowDomain,
- //setting.CORSConfig.AllowSubdomain // FIXME: the cors middleware needs allowSubdomain option
+ // setting.CORSConfig.AllowSubdomain // FIXME: the cors middleware needs allowSubdomain option
AllowedMethods: setting.CORSConfig.Methods,
AllowCredentials: setting.CORSConfig.AllowCredentials,
AllowedHeaders: []string{"Authorization", "X-CSRFToken", "X-Gitea-OTP"},
diff --git a/routers/api/v1/misc/markdown_test.go b/routers/api/v1/misc/markdown_test.go
index dc6762c4cf..349498e2ab 100644
--- a/routers/api/v1/misc/markdown_test.go
+++ b/routers/api/v1/misc/markdown_test.go
@@ -22,12 +22,14 @@ import (
"github.com/stretchr/testify/assert"
)
-const AppURL = "http://localhost:3000/"
-const Repo = "gogits/gogs"
-const AppSubURL = AppURL + Repo + "/"
+const (
+ AppURL = "http://localhost:3000/"
+ Repo = "gogits/gogs"
+ AppSubURL = AppURL + Repo + "/"
+)
func createContext(req *http.Request) (*context.Context, *httptest.ResponseRecorder) {
- var rnd = templates.HTMLRenderer()
+ rnd := templates.HTMLRenderer()
resp := httptest.NewRecorder()
c := &context.Context{
Req: req,
diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go
index b9d1fa2f67..67957430d1 100644
--- a/routers/api/v1/org/hook.go
+++ b/routers/api/v1/org/hook.go
@@ -123,7 +123,7 @@ func CreateHook(ctx *context.APIContext) {
// "$ref": "#/responses/Hook"
form := web.GetForm(ctx).(*api.CreateHookOption)
- //TODO in body params
+ // TODO in body params
if !utils.CheckCreateHookOption(ctx, form) {
return
}
@@ -161,7 +161,7 @@ func EditHook(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.EditHookOption)
- //TODO in body params
+ // TODO in body params
hookID := ctx.ParamsInt64(":id")
utils.EditOrgHook(ctx, form, hookID)
}
diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go
index 133cce3416..1f097225f2 100644
--- a/routers/api/v1/org/org.go
+++ b/routers/api/v1/org/org.go
@@ -25,7 +25,7 @@ func listUserOrgs(ctx *context.APIContext, u *user_model.User) {
listOptions := utils.GetListOptions(ctx)
showPrivate := ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == u.ID)
- var opts = models.FindOrgOptions{
+ opts := models.FindOrgOptions{
ListOptions: listOptions,
UserID: u.ID,
IncludePrivate: showPrivate,
@@ -357,7 +357,7 @@ func Edit(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, convert.ToOrganization(org))
}
-//Delete an organization
+// Delete an organization
func Delete(ctx *context.APIContext) {
// swagger:operation DELETE /orgs/{org} organization orgDelete
// ---
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go
index c5480bf2c5..3a0c3201ac 100644
--- a/routers/api/v1/repo/branch.go
+++ b/routers/api/v1/repo/branch.go
@@ -177,23 +177,18 @@ func CreateBranch(ctx *context.APIContext) {
}
err := repo_service.CreateNewBranch(ctx, ctx.User, ctx.Repo.Repository, opt.OldBranchName, opt.BranchName)
-
if err != nil {
if models.IsErrBranchDoesNotExist(err) {
ctx.Error(http.StatusNotFound, "", "The old branch does not exist")
}
if models.IsErrTagAlreadyExists(err) {
ctx.Error(http.StatusConflict, "", "The branch with the same tag already exists.")
-
} else if models.IsErrBranchAlreadyExists(err) || git.IsErrPushOutOfDate(err) {
ctx.Error(http.StatusConflict, "", "The branch already exists.")
-
} else if models.IsErrBranchNameConflict(err) {
ctx.Error(http.StatusConflict, "", "The branch with the same name already exists.")
-
} else {
ctx.Error(http.StatusInternalServerError, "CreateRepoBranch", err)
-
}
return
}
@@ -532,7 +527,6 @@ func CreateBranchProtection(ctx *context.APIContext) {
}
ctx.JSON(http.StatusCreated, convert.ToBranchProtection(bp))
-
}
// EditBranchProtection edits a branch protection for a repo
diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go
index b0ba5db253..d814ae909e 100644
--- a/routers/api/v1/repo/fork.go
+++ b/routers/api/v1/repo/fork.go
@@ -149,6 +149,6 @@ func CreateFork(ctx *context.APIContext) {
return
}
- //TODO change back to 201
+ // TODO change back to 201
ctx.JSON(http.StatusAccepted, convert.ToRepo(fork, perm.AccessModeOwner))
}
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 5137c7246e..5ce0c109e6 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -599,7 +599,7 @@ func CreateIssue(ctx *context.APIContext) {
DeadlineUnix: deadlineUnix,
}
- var assigneeIDs = make([]int64, 0)
+ assigneeIDs := make([]int64, 0)
var err error
if ctx.Repo.CanWrite(unit.TypeIssues) {
issue.MilestoneID = form.Milestone
diff --git a/routers/api/v1/repo/issue_reaction.go b/routers/api/v1/repo/issue_reaction.go
index 6184ea71f0..9c5086700c 100644
--- a/routers/api/v1/repo/issue_reaction.go
+++ b/routers/api/v1/repo/issue_reaction.go
@@ -225,7 +225,7 @@ func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOp
ctx.Error(http.StatusInternalServerError, "DeleteCommentReaction", err)
return
}
- //ToDo respond 204
+ // ToDo respond 204
ctx.Status(http.StatusOK)
}
}
@@ -435,7 +435,7 @@ func changeIssueReaction(ctx *context.APIContext, form api.EditReactionOption, i
ctx.Error(http.StatusInternalServerError, "DeleteIssueReaction", err)
return
}
- //ToDo respond 204
+ // ToDo respond 204
ctx.Status(http.StatusOK)
}
}
diff --git a/routers/api/v1/repo/issue_subscription.go b/routers/api/v1/repo/issue_subscription.go
index 9c6b4e4647..76c668697e 100644
--- a/routers/api/v1/repo/issue_subscription.go
+++ b/routers/api/v1/repo/issue_subscription.go
@@ -127,7 +127,7 @@ func setIssueSubscription(ctx *context.APIContext, watch bool) {
return
}
- //only admin and user for itself can change subscription
+ // only admin and user for itself can change subscription
if user.ID != ctx.User.ID && !ctx.User.IsAdmin {
ctx.Error(http.StatusForbidden, "User", fmt.Errorf("%s is not permitted to change subscriptions for %s", ctx.User.Name, user.Name))
return
@@ -269,7 +269,7 @@ func GetIssueSubscribers(ctx *context.APIContext) {
return
}
- var userIDs = make([]int64, 0, len(iwl))
+ userIDs := make([]int64, 0, len(iwl))
for _, iw := range iwl {
userIDs = append(userIDs, iw.UserID)
}
diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go
index 00f8e77feb..79ba59996c 100644
--- a/routers/api/v1/repo/issue_tracked_time.go
+++ b/routers/api/v1/repo/issue_tracked_time.go
@@ -201,7 +201,7 @@ func AddTime(ctx *context.APIContext) {
user := ctx.User
if form.User != "" {
if (ctx.IsUserRepoAdmin() && ctx.User.Name != form.User) || ctx.User.IsAdmin {
- //allow only RepoAdmin, Admin and User to add time
+ // allow only RepoAdmin, Admin and User to add time
user, err = user_model.GetUserByName(form.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserByName", err)
@@ -365,7 +365,7 @@ func DeleteTime(ctx *context.APIContext) {
}
if !ctx.User.IsAdmin && time.UserID != ctx.User.ID {
- //Only Admin and User itself can delete their time
+ // Only Admin and User itself can delete their time
ctx.Status(http.StatusForbidden)
return
}
diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go
index 8a6f421c87..394504a99d 100644
--- a/routers/api/v1/repo/migrate.go
+++ b/routers/api/v1/repo/migrate.go
@@ -56,7 +56,7 @@ func Migrate(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.MigrateRepoOptions)
- //get repoOwner
+ // get repoOwner
var (
repoOwner *user_model.User
err error
@@ -137,7 +137,7 @@ func Migrate(ctx *context.APIContext) {
}
}
- var opts = migrations.MigrateOptions{
+ opts := migrations.MigrateOptions{
CloneAddr: remoteAddr,
RepoName: form.RepoName,
Description: form.Description,
diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go
index be1da18c5d..3b4b85158c 100644
--- a/routers/api/v1/repo/milestone.go
+++ b/routers/api/v1/repo/milestone.go
@@ -213,7 +213,7 @@ func EditMilestone(ctx *context.APIContext) {
milestone.DeadlineUnix = timeutil.TimeStamp(form.Deadline.Unix())
}
- var oldIsClosed = milestone.IsClosed
+ oldIsClosed := milestone.IsClosed
if form.State != nil {
milestone.IsClosed = *form.State == string(api.StateClosed)
}
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 52ff8425de..a494cb06cc 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -95,7 +95,6 @@ func ListPullRequests(ctx *context.APIContext) {
Labels: ctx.FormStrings("labels"),
MilestoneID: ctx.FormInt64("milestone"),
})
-
if err != nil {
ctx.Error(http.StatusInternalServerError, "PullRequests", err)
return
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go
index fe82915a94..b1bc48d30f 100644
--- a/routers/api/v1/repo/release_attachment.go
+++ b/routers/api/v1/repo/release_attachment.go
@@ -178,7 +178,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
}
defer file.Close()
- var filename = header.Filename
+ filename := header.Filename
if query := ctx.FormString("name"); query != "" {
filename = query
}
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 5f17dc9268..c2dfc4f193 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -160,7 +160,7 @@ func Search(ctx *context.APIContext) {
opts.Collaborate = util.OptionalBoolFalse
}
- var mode = ctx.FormString("mode")
+ mode := ctx.FormString("mode")
switch mode {
case "source":
opts.Fork = util.OptionalBoolFalse
@@ -186,9 +186,9 @@ func Search(ctx *context.APIContext) {
opts.IsPrivate = util.OptionalBoolOf(ctx.FormBool("is_private"))
}
- var sortMode = ctx.FormString("sort")
+ sortMode := ctx.FormString("sort")
if len(sortMode) > 0 {
- var sortOrder = ctx.FormString("order")
+ sortOrder := ctx.FormString("order")
if len(sortOrder) == 0 {
sortOrder = "asc"
}
diff --git a/routers/api/v1/repo/repo_test.go b/routers/api/v1/repo/repo_test.go
index 17b49f7f58..652fecefbc 100644
--- a/routers/api/v1/repo/repo_test.go
+++ b/routers/api/v1/repo/repo_test.go
@@ -55,7 +55,7 @@ func TestRepoEdit(t *testing.T) {
Archived: &archived,
}
- var apiCtx = &context.APIContext{Context: ctx, Org: nil}
+ apiCtx := &context.APIContext{Context: ctx, Org: nil}
web.SetForm(apiCtx, &opts)
Edit(apiCtx)
@@ -77,7 +77,7 @@ func TestRepoEditNameChange(t *testing.T) {
Name: &name,
}
- var apiCtx = &context.APIContext{Context: ctx, Org: nil}
+ apiCtx := &context.APIContext{Context: ctx, Org: nil}
web.SetForm(apiCtx, &opts)
Edit(apiCtx)
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index 72d790794e..01faf5ad25 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -176,7 +176,7 @@ func GetCommitStatusesByRef(ctx *context.APIContext) {
return
}
- getCommitStatuses(ctx, filter) //By default filter is maybe the raw SHA
+ getCommitStatuses(ctx, filter) // By default filter is maybe the raw SHA
}
func getCommitStatuses(ctx *context.APIContext, sha string) {
diff --git a/routers/api/v1/repo/wiki.go b/routers/api/v1/repo/wiki.go
index 94f1dbe0ea..f7054b5067 100644
--- a/routers/api/v1/repo/wiki.go
+++ b/routers/api/v1/repo/wiki.go
@@ -167,7 +167,7 @@ func getWikiPage(ctx *context.APIContext, title string) *api.WikiPage {
return nil
}
- //lookup filename in wiki - get filecontent, real filename
+ // lookup filename in wiki - get filecontent, real filename
content, pageFilename := wikiContentsByName(ctx, commit, title, false)
if ctx.Written() {
return nil
@@ -412,7 +412,7 @@ func ListPageRevisions(ctx *context.APIContext) {
pageName = "Home"
}
- //lookup filename in wiki - get filecontent, gitTree entry , real filename
+ // lookup filename in wiki - get filecontent, gitTree entry , real filename
_, pageFilename := wikiContentsByName(ctx, commit, pageName, false)
if ctx.Written() {
return
@@ -501,7 +501,6 @@ func wikiContentsByEntry(ctx *context.APIContext, entry *git.TreeEntry) string {
func wikiContentsByName(ctx *context.APIContext, commit *git.Commit, wikiName string, isSidebarOrFooter bool) (string, string) {
pageFilename := wiki_service.NameToFilename(wikiName)
entry, err := findEntryForFile(commit, pageFilename)
-
if err != nil {
if git.IsErrNotExist(err) {
if !isSidebarOrFooter {
diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go
index a90e8c30f0..26aeeeabf9 100644
--- a/routers/api/v1/user/gpg_key.go
+++ b/routers/api/v1/user/gpg_key.go
@@ -39,7 +39,7 @@ func listGPGKeys(ctx *context.APIContext, uid int64, listOptions db.ListOptions)
ctx.JSON(http.StatusOK, &apiKeys)
}
-//ListGPGKeys get the GPG key list of a user
+// ListGPGKeys get the GPG key list of a user
func ListGPGKeys(ctx *context.APIContext) {
// swagger:operation GET /users/{username}/gpg_keys user userListGPGKeys
// ---
@@ -71,7 +71,7 @@ func ListGPGKeys(ctx *context.APIContext) {
listGPGKeys(ctx, user.ID, utils.GetListOptions(ctx))
}
-//ListMyGPGKeys get the GPG key list of the authenticated user
+// ListMyGPGKeys get the GPG key list of the authenticated user
func ListMyGPGKeys(ctx *context.APIContext) {
// swagger:operation GET /user/gpg_keys user userCurrentListGPGKeys
// ---
@@ -94,7 +94,7 @@ func ListMyGPGKeys(ctx *context.APIContext) {
listGPGKeys(ctx, ctx.User.ID, utils.GetListOptions(ctx))
}
-//GetGPGKey get the GPG key based on a id
+// GetGPGKey get the GPG key based on a id
func GetGPGKey(ctx *context.APIContext) {
// swagger:operation GET /user/gpg_keys/{id} user userCurrentGetGPGKey
// ---
@@ -212,7 +212,7 @@ type swaggerUserCurrentPostGPGKey struct {
Form api.CreateGPGKeyOption
}
-//CreateGPGKey create a GPG key belonging to the authenticated user
+// CreateGPGKey create a GPG key belonging to the authenticated user
func CreateGPGKey(ctx *context.APIContext) {
// swagger:operation POST /user/gpg_keys user userCurrentPostGPGKey
// ---
@@ -233,7 +233,7 @@ func CreateGPGKey(ctx *context.APIContext) {
CreateUserGPGKey(ctx, *form, ctx.User.ID)
}
-//DeleteGPGKey remove a GPG key belonging to the authenticated user
+// DeleteGPGKey remove a GPG key belonging to the authenticated user
func DeleteGPGKey(ctx *context.APIContext) {
// swagger:operation DELETE /user/gpg_keys/{id} user userCurrentDeleteGPGKey
// ---
diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go
index 6c3e1c86fa..49b1d47d95 100644
--- a/routers/api/v1/user/watch.go
+++ b/routers/api/v1/user/watch.go
@@ -170,7 +170,6 @@ func Watch(ctx *context.APIContext) {
URL: subscriptionURL(ctx.Repo.Repository),
RepositoryURL: ctx.Repo.Repository.APIURL(),
})
-
}
// Unwatch the repo specified in ctx, as the authenticated user
diff --git a/routers/api/v1/utils/git.go b/routers/api/v1/utils/git.go
index a941c1fc2c..f7a7fe83c9 100644
--- a/routers/api/v1/utils/git.go
+++ b/routers/api/v1/utils/git.go
@@ -50,12 +50,12 @@ func GetGitRefs(ctx *context.APIContext, filter string) ([]*git.Reference, strin
}
func searchRefCommitByType(ctx *context.APIContext, refType, filter string) (string, string, error) {
- refs, lastMethodName, err := GetGitRefs(ctx, refType+"/"+filter) //Search by type
+ refs, lastMethodName, err := GetGitRefs(ctx, refType+"/"+filter) // Search by type
if err != nil {
return "", lastMethodName, err
}
if len(refs) > 0 {
- return refs[0].Object.String(), "", nil //Return found SHA
+ return refs[0].Object.String(), "", nil // Return found SHA
}
return "", "", nil
}
diff --git a/routers/common/middleware.go b/routers/common/middleware.go
index 2b6343b10f..880700969a 100644
--- a/routers/common/middleware.go
+++ b/routers/common/middleware.go
@@ -21,7 +21,7 @@ import (
// Middlewares returns common middlewares
func Middlewares() []func(http.Handler) http.Handler {
- var handlers = []func(http.Handler) http.Handler{
+ handlers := []func(http.Handler) http.Handler{
func(next http.Handler) http.Handler {
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
// First of all escape the URL RawPath to ensure that all routing is done using a correctly escaped URL
diff --git a/routers/install/install.go b/routers/install/install.go
index 230f6e0602..043fae26de 100644
--- a/routers/install/install.go
+++ b/routers/install/install.go
@@ -54,7 +54,7 @@ func getDbTypeNames() []map[string]string {
// Init prepare for rendering installation page
func Init(next http.Handler) http.Handler {
- var rnd = templates.HTMLRenderer()
+ rnd := templates.HTMLRenderer()
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
if setting.InstallLock {
@@ -62,9 +62,9 @@ func Init(next http.Handler) http.Handler {
_ = rnd.HTML(resp, 200, string(tplPostInstall), nil)
return
}
- var locale = middleware.Locale(resp, req)
- var startTime = time.Now()
- var ctx = context.Context{
+ locale := middleware.Locale(resp, req)
+ startTime := time.Now()
+ ctx := context.Context{
Resp: context.NewResponse(resp),
Flash: &middleware.Flash{},
Locale: locale,
diff --git a/routers/install/routes.go b/routers/install/routes.go
index d7d8527cf5..f377cd40c9 100644
--- a/routers/install/routes.go
+++ b/routers/install/routes.go
@@ -28,7 +28,7 @@ func (d *dataStore) GetData() map[string]interface{} {
}
func installRecovery() func(next http.Handler) http.Handler {
- var rnd = templates.HTMLRenderer()
+ rnd := templates.HTMLRenderer()
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
defer func() {
@@ -53,7 +53,7 @@ func installRecovery() func(next http.Handler) http.Handler {
log.Error("%s", combinedErr)
lc := middleware.Locale(w, req)
- var store = dataStore{
+ store := dataStore{
"Language": lc.Language(),
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
"i18n": lc,
diff --git a/routers/private/internal.go b/routers/private/internal.go
index 4960f561c1..263180bd58 100644
--- a/routers/private/internal.go
+++ b/routers/private/internal.go
@@ -35,12 +35,12 @@ func CheckInternalToken(next http.Handler) http.Handler {
// bind binding an obj to a handler
func bind(obj interface{}) http.HandlerFunc {
- var tp = reflect.TypeOf(obj)
+ tp := reflect.TypeOf(obj)
for tp.Kind() == reflect.Ptr {
tp = tp.Elem()
}
return web.Wrap(func(ctx *context.PrivateContext) {
- var theObj = reflect.New(tp).Interface() // create a new form obj for every request but not use obj directly
+ theObj := reflect.New(tp).Interface() // create a new form obj for every request but not use obj directly
binding.Bind(ctx.Req, theObj)
web.SetForm(ctx, theObj)
})
@@ -49,7 +49,7 @@ func bind(obj interface{}) http.HandlerFunc {
// Routes registers all internal APIs routes to web application.
// These APIs will be invoked by internal commands for example `gitea serv` and etc.
func Routes() *web.Route {
- var r = web.NewRoute()
+ r := web.NewRoute()
r.Use(context.PrivateContexter())
r.Use(CheckInternalToken)
diff --git a/routers/private/manager_unix.go b/routers/private/manager_unix.go
index f00f202207..402bade5d4 100644
--- a/routers/private/manager_unix.go
+++ b/routers/private/manager_unix.go
@@ -18,7 +18,6 @@ import (
func Restart(ctx *context.PrivateContext) {
graceful.GetManager().DoGracefulRestart()
ctx.PlainText(http.StatusOK, "success")
-
}
// Shutdown causes the server to perform a graceful shutdown
diff --git a/routers/private/restore_repo.go b/routers/private/restore_repo.go
index 85aada192f..8dfe569325 100644
--- a/routers/private/restore_repo.go
+++ b/routers/private/restore_repo.go
@@ -23,7 +23,7 @@ func RestoreRepo(ctx *myCtx.PrivateContext) {
})
return
}
- var params = struct {
+ params := struct {
RepoDir string
OwnerName string
RepoName string
diff --git a/routers/web/admin/admin.go b/routers/web/admin/admin.go
index 7e25f96ee0..276e1939ad 100644
--- a/routers/web/admin/admin.go
+++ b/routers/web/admin/admin.go
@@ -209,7 +209,7 @@ func shadowPassword(provider, cfgItem string) string {
case "redis":
return shadowPasswordKV(cfgItem, ",")
case "mysql":
- //root:@tcp(localhost:3306)/macaron?charset=utf8
+ // root:@tcp(localhost:3306)/macaron?charset=utf8
atIdx := strings.Index(cfgItem, "@")
if atIdx > 0 {
colonIdx := strings.Index(cfgItem[:atIdx], ":")
diff --git a/routers/web/admin/admin_test.go b/routers/web/admin/admin_test.go
index da404e50d7..1bc43998b2 100644
--- a/routers/web/admin/admin_test.go
+++ b/routers/web/admin/admin_test.go
@@ -11,7 +11,7 @@ import (
)
func TestShadowPassword(t *testing.T) {
- var kases = []struct {
+ kases := []struct {
Provider string
CfgItem string
Result string
diff --git a/routers/web/admin/emails.go b/routers/web/admin/emails.go
index cbf0ec5e98..b94f9d72c4 100644
--- a/routers/web/admin/emails.go
+++ b/routers/web/admin/emails.go
@@ -101,9 +101,7 @@ func Emails(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplEmails)
}
-var (
- nullByte = []byte{0x00}
-)
+var nullByte = []byte{0x00}
func isKeywordValid(keyword string) bool {
return !bytes.Contains([]byte(keyword), nullByte)
@@ -111,7 +109,6 @@ func isKeywordValid(keyword string) bool {
// ActivateEmail serves a POST request for activating/deactivating a user's email
func ActivateEmail(ctx *context.Context) {
-
truefalse := map[string]bool{"1": true, "0": false}
uid := ctx.FormInt64("uid")
diff --git a/routers/web/admin/users_test.go b/routers/web/admin/users_test.go
index 1849781bc4..46133688a5 100644
--- a/routers/web/admin/users_test.go
+++ b/routers/web/admin/users_test.go
@@ -19,7 +19,6 @@ import (
)
func TestNewUserPost_MustChangePassword(t *testing.T) {
-
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "admin/users/new")
diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go
index d6b3635584..ce8ec8a1e3 100644
--- a/routers/web/auth/auth.go
+++ b/routers/web/auth/auth.go
@@ -297,7 +297,7 @@ func handleSignIn(ctx *context.Context, u *user_model.User, remember bool) {
ctx.Redirect(redirect)
}
-func handleSignInFull(ctx *context.Context, u *user_model.User, remember bool, obeyRedirect bool) string {
+func handleSignInFull(ctx *context.Context, u *user_model.User, remember, obeyRedirect bool) string {
if remember {
days := 86400 * setting.LogInRememberDays
ctx.SetCookie(setting.CookieUserName, u.Name, days)
@@ -417,7 +417,7 @@ func SignUp(ctx *context.Context) {
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
ctx.Data["PageIsSignUp"] = true
- //Show Disabled Registration message if DisableRegistration or AllowOnlyExternalRegistration options are true
+ // Show Disabled Registration message if DisableRegistration or AllowOnlyExternalRegistration options are true
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration || setting.Service.AllowOnlyExternalRegistration
ctx.HTML(http.StatusOK, tplSignUp)
@@ -438,7 +438,7 @@ func SignUpPost(ctx *context.Context) {
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
ctx.Data["PageIsSignUp"] = true
- //Permission denied if DisableRegistration or AllowOnlyExternalRegistration options are true
+ // Permission denied if DisableRegistration or AllowOnlyExternalRegistration options are true
if setting.Service.DisableRegistration || setting.Service.AllowOnlyExternalRegistration {
ctx.Error(http.StatusForbidden)
return
diff --git a/routers/web/auth/linkaccount.go b/routers/web/auth/linkaccount.go
index 27eb954a58..bf5fb83265 100644
--- a/routers/web/auth/linkaccount.go
+++ b/routers/web/auth/linkaccount.go
@@ -27,9 +27,7 @@ import (
"github.com/markbates/goth"
)
-var (
- tplLinkAccount base.TplName = "user/auth/link_account"
-)
+var tplLinkAccount base.TplName = "user/auth/link_account"
// LinkAccount shows the page where the user can decide to login or create a new account
func LinkAccount(ctx *context.Context) {
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index fa2b0aa65f..7bf1adf308 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -1158,5 +1158,4 @@ func oAuth2UserLoginCallback(authSource *auth.Source, request *http.Request, res
// no user found to login
return nil, gothUser, nil
-
}
diff --git a/routers/web/auth/openid.go b/routers/web/auth/openid.go
index 4395641795..e0c6069546 100644
--- a/routers/web/auth/openid.go
+++ b/routers/web/auth/openid.go
@@ -67,7 +67,6 @@ func SignInOpenID(ctx *context.Context) {
// Check if the given OpenID URI is allowed by blacklist/whitelist
func allowedOpenIDURI(uri string) (err error) {
-
// In case a Whitelist is present, URI must be in it
// in order to be accepted
if len(setting.Service.OpenIDWhitelist) != 0 {
@@ -144,13 +143,12 @@ func SignInOpenIDPost(ctx *context.Context) {
// signInOpenIDVerify handles response from OpenID provider
func signInOpenIDVerify(ctx *context.Context) {
-
log.Trace("Incoming call to: %s", ctx.Req.URL.String())
fullURL := setting.AppURL + ctx.Req.URL.String()[1:]
log.Trace("Full URL: %s", fullURL)
- var id, err = openid.Verify(fullURL)
+ id, err := openid.Verify(fullURL)
if err != nil {
ctx.RenderWithErr(err.Error(), tplSignInOpenID, &forms.SignInOpenIDForm{
Openid: id,
diff --git a/routers/web/auth/webauthn.go b/routers/web/auth/webauthn.go
index 77b1bee18a..bedbe7ddc3 100644
--- a/routers/web/auth/webauthn.go
+++ b/routers/web/auth/webauthn.go
@@ -33,7 +33,7 @@ func WebAuthn(ctx *context.Context) {
return
}
- //Ensure user is in a 2FA session.
+ // Ensure user is in a 2FA session.
if ctx.Session.Get("twofaUid") == nil {
ctx.ServerError("UserSignIn", errors.New("not in WebAuthn session"))
return
diff --git a/routers/web/base.go b/routers/web/base.go
index fd942d3c87..f7eb003cc4 100644
--- a/routers/web/base.go
+++ b/routers/web/base.go
@@ -92,7 +92,7 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor
return
}
- //If we have matched and access to release or issue
+ // If we have matched and access to release or issue
fr, err := objStore.Open(rPath)
if err != nil {
if os.IsNotExist(err) || errors.Is(err, os.ErrNotExist) {
@@ -125,7 +125,7 @@ func (d *dataStore) GetData() map[string]interface{} {
// Recovery returns a middleware that recovers from any panics and writes a 500 and a log if so.
// This error will be created with the gitea 500 page.
func Recovery() func(next http.Handler) http.Handler {
- var rnd = templates.HTMLRenderer()
+ rnd := templates.HTMLRenderer()
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
defer func() {
@@ -136,14 +136,14 @@ func Recovery() func(next http.Handler) http.Handler {
sessionStore := session.GetSession(req)
- var lc = middleware.Locale(w, req)
- var store = dataStore{
+ lc := middleware.Locale(w, req)
+ store := dataStore{
"Language": lc.Language(),
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
"i18n": lc,
}
- var user = context.GetContextUser(req)
+ user := context.GetContextUser(req)
if user == nil {
// Get user from session if logged in - do not attempt to sign-in
user = auth.SessionUser(sessionStore)
diff --git a/routers/web/explore/code.go b/routers/web/explore/code.go
index b61f25a96c..d2acefde92 100644
--- a/routers/web/explore/code.go
+++ b/routers/web/explore/code.go
@@ -76,7 +76,7 @@ func Code(ctx *context.Context) {
return
}
- var rightRepoMap = make(map[int64]*repo_model.Repository, len(repoMaps))
+ rightRepoMap := make(map[int64]*repo_model.Repository, len(repoMaps))
repoIDs = make([]int64, 0, len(repoMaps))
for id, repo := range repoMaps {
if models.CheckRepoUnitUser(repo, ctx.User, unit.TypeCode) {
@@ -100,7 +100,7 @@ func Code(ctx *context.Context) {
return
}
- var loadRepoIDs = make([]int64, 0, len(searchResults))
+ loadRepoIDs := make([]int64, 0, len(searchResults))
for _, result := range searchResults {
var find bool
for _, id := range loadRepoIDs {
diff --git a/routers/web/explore/user.go b/routers/web/explore/user.go
index 27634c3d4e..b264bf1b4a 100644
--- a/routers/web/explore/user.go
+++ b/routers/web/explore/user.go
@@ -25,9 +25,7 @@ const (
// UserSearchDefaultSortType is the default sort type for user search
const UserSearchDefaultSortType = "alphabetically"
-var (
- nullByte = []byte{0x00}
-)
+var nullByte = []byte{0x00}
func isKeywordValid(keyword string) bool {
return !bytes.Contains([]byte(keyword), nullByte)
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index 43f6211af3..cf23a1e291 100644
--- a/routers/web/org/home.go
+++ b/routers/web/org/home.go
@@ -110,7 +110,7 @@ func Home(ctx *context.Context) {
return
}
- var opts = &models.FindOrgMembersOpts{
+ opts := &models.FindOrgMembersOpts{
OrgID: org.ID,
PublicOnly: true,
ListOptions: db.ListOptions{Page: 1, PageSize: 25},
diff --git a/routers/web/org/members.go b/routers/web/org/members.go
index e9b7317c98..b8e7fa1ff5 100644
--- a/routers/web/org/members.go
+++ b/routers/web/org/members.go
@@ -31,7 +31,7 @@ func Members(ctx *context.Context) {
page = 1
}
- var opts = &models.FindOrgMembersOpts{
+ opts := &models.FindOrgMembersOpts{
OrgID: org.ID,
PublicOnly: true,
}
diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go
index 747a5134b4..404aac8894 100644
--- a/routers/web/org/setting.go
+++ b/routers/web/org/setting.go
@@ -117,7 +117,8 @@ func SettingsPost(ctx *context.Context) {
// update forks visibility
if visibilityChanged {
repos, _, err := models.GetUserRepositories(&models.SearchRepoOptions{
- Actor: org.AsUser(), Private: true, ListOptions: db.ListOptions{Page: 1, PageSize: org.NumRepos}})
+ Actor: org.AsUser(), Private: true, ListOptions: db.ListOptions{Page: 1, PageSize: org.NumRepos},
+ })
if err != nil {
ctx.ServerError("GetRepositories", err)
return
diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go
index 303eee24d1..4101d81ac5 100644
--- a/routers/web/repo/attachment.go
+++ b/routers/web/repo/attachment.go
@@ -100,12 +100,12 @@ func GetAttachment(ctx *context.Context) {
return
}
- if repository == nil { //If not linked
- if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) { //We block if not the uploader
+ if repository == nil { // If not linked
+ if !(ctx.IsSigned && attach.UploaderID == ctx.User.ID) { // We block if not the uploader
ctx.Error(http.StatusNotFound)
return
}
- } else { //If we have the repository we check access
+ } else { // If we have the repository we check access
perm, err := models.GetUserRepoPermission(repository, ctx.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err.Error())
@@ -123,7 +123,7 @@ func GetAttachment(ctx *context.Context) {
}
if setting.Attachment.ServeDirect {
- //If we have a signed url (S3, object storage), redirect to this directly.
+ // If we have a signed url (S3, object storage), redirect to this directly.
u, err := storage.Attachments.URL(attach.RelativePath(), attach.Name)
if u != nil && err == nil {
@@ -136,7 +136,7 @@ func GetAttachment(ctx *context.Context) {
return
}
- //If we have matched and access to release or issue
+ // If we have matched and access to release or issue
fr, err := storage.Attachments.Open(attach.RelativePath())
if err != nil {
ctx.ServerError("Open", err)
diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go
index bff6a039e8..588e432e3a 100644
--- a/routers/web/repo/blame.go
+++ b/routers/web/repo/blame.go
@@ -233,12 +233,12 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
language = ""
}
}
- var lines = make([]string, 0)
+ lines := make([]string, 0)
rows := make([]*blameRow, 0)
escapeStatus := charset.EscapeStatus{}
- var i = 0
- var commitCnt = 0
+ i := 0
+ commitCnt := 0
for _, part := range blameParts {
for index, line := range part.Lines {
i++
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go
index ed1b2a9b1a..5d19fd1185 100644
--- a/routers/web/repo/branch.go
+++ b/routers/web/repo/branch.go
@@ -203,7 +203,7 @@ func loadBranches(ctx *context.Context, skip, limit int) (*Branch, []*Branch, in
continue
}
- var branch = loadOneBranch(ctx, rawBranches[i], defaultBranch, protectedBranches, repoIDToRepo, repoIDToGitRepo)
+ branch := loadOneBranch(ctx, rawBranches[i], defaultBranch, protectedBranches, repoIDToRepo, repoIDToGitRepo)
if branch == nil {
return nil, nil, 0
}
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index 22e6be2021..cdb6f9d7fe 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -111,7 +111,7 @@ func setCsvCompareContext(ctx *context.Context) {
Error string
}
- ctx.Data["CreateCsvDiff"] = func(diffFile *gitdiff.DiffFile, baseCommit *git.Commit, headCommit *git.Commit) CsvDiffResult {
+ ctx.Data["CreateCsvDiff"] = func(diffFile *gitdiff.DiffFile, baseCommit, headCommit *git.Commit) CsvDiffResult {
if diffFile == nil || baseCommit == nil || headCommit == nil {
return CsvDiffResult{nil, ""}
}
@@ -541,8 +541,8 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
func PrepareCompareDiff(
ctx *context.Context,
ci *CompareInfo,
- whitespaceBehavior string) bool {
-
+ whitespaceBehavior string,
+) bool {
var (
repo = ctx.Repo.Repository
err error
@@ -839,7 +839,8 @@ func ExcerptBlob(ctx *context.Context) {
RightIdx: idxRight,
LeftHunkSize: leftHunkSize,
RightHunkSize: rightHunkSize,
- }}
+ },
+ }
if direction == "up" {
section.Lines = append([]*gitdiff.DiffLine{lineSection}, section.Lines...)
} else if direction == "down" {
diff --git a/routers/web/repo/download.go b/routers/web/repo/download.go
index 430de24c69..72d34cb937 100644
--- a/routers/web/repo/download.go
+++ b/routers/web/repo/download.go
@@ -52,7 +52,7 @@ func ServeBlobOrLFS(ctx *context.Context, blob *git.Blob) error {
}
if setting.LFS.ServeDirect {
- //If we have a signed url (S3, object storage), redirect to this directly.
+ // If we have a signed url (S3, object storage), redirect to this directly.
u, err := storage.LFS.URL(pointer.RelativePath(), blob.Name())
if u != nil && err == nil {
ctx.Redirect(u.String())
diff --git a/routers/web/repo/editor_test.go b/routers/web/repo/editor_test.go
index 77f94ff550..ab7532ebb5 100644
--- a/routers/web/repo/editor_test.go
+++ b/routers/web/repo/editor_test.go
@@ -17,7 +17,7 @@ import (
func TestCleanUploadName(t *testing.T) {
unittest.PrepareTestEnv(t)
- var kases = map[string]string{
+ kases := map[string]string{
".git/refs/master": "",
"/root/abc": "root/abc",
"./../../abc": "abc",
diff --git a/routers/web/repo/http.go b/routers/web/repo/http.go
index 5e73843920..3805ceea76 100644
--- a/routers/web/repo/http.go
+++ b/routers/web/repo/http.go
@@ -104,7 +104,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
}
isWiki := false
- var unitType = unit.TypeCode
+ unitType := unit.TypeCode
var wikiRepoName string
if strings.HasSuffix(reponame, ".wiki") {
isWiki = true
@@ -457,7 +457,6 @@ func serviceRPC(ctx gocontext.Context, h serviceHandler, service string) {
if err := h.r.Body.Close(); err != nil {
log.Error("serviceRPC: Close: %v", err)
}
-
}()
if !hasAccess(ctx, service, h, true) {
@@ -468,7 +467,7 @@ func serviceRPC(ctx gocontext.Context, h serviceHandler, service string) {
h.w.Header().Set("Content-Type", fmt.Sprintf("application/x-git-%s-result", service))
var err error
- var reqBody = h.r.Body
+ reqBody := h.r.Body
// Handle GZIP.
if h.r.Header.Get("Content-Encoding") == "gzip" {
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index ba871127f7..aff5fa8498 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -57,17 +57,15 @@ const (
issueTemplateTitleKey = "IssueTemplateTitle"
)
-var (
- // IssueTemplateCandidates issue templates
- IssueTemplateCandidates = []string{
- "ISSUE_TEMPLATE.md",
- "issue_template.md",
- ".gitea/ISSUE_TEMPLATE.md",
- ".gitea/issue_template.md",
- ".github/ISSUE_TEMPLATE.md",
- ".github/issue_template.md",
- }
-)
+// IssueTemplateCandidates issue templates
+var IssueTemplateCandidates = []string{
+ "ISSUE_TEMPLATE.md",
+ "issue_template.md",
+ ".gitea/ISSUE_TEMPLATE.md",
+ ".gitea/issue_template.md",
+ ".github/ISSUE_TEMPLATE.md",
+ ".github/issue_template.md",
+}
// MustAllowUserComment checks to make sure if an issue is locked.
// If locked and user has permissions to write to the repository,
@@ -245,7 +243,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
}
}
- var issueList = models.IssueList(issues)
+ issueList := models.IssueList(issues)
approvalCounts, err := issueList.GetApprovalCounts()
if err != nil {
ctx.ServerError("ApprovalCounts", err)
@@ -311,8 +309,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
}
- ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] =
- issue_service.GetRefEndNamesAndURLs(issues, ctx.Repo.RepoLink)
+ ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] = issue_service.GetRefEndNamesAndURLs(issues, ctx.Repo.RepoLink)
ctx.Data["ApprovalCounts"] = func(issueID int64, typ string) int64 {
counts, ok := approvalCounts[issueID]
@@ -442,7 +439,6 @@ func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *repo_model.R
}
func retrieveProjects(ctx *context.Context, repo *repo_model.Repository) {
-
var err error
ctx.Data["OpenProjects"], _, err = models.GetProjects(models.ProjectSearchOptions{
@@ -2508,7 +2504,7 @@ func filterXRefComments(ctx *context.Context, issue *models.Issue) error {
// GetIssueAttachments returns attachments for the issue
func GetIssueAttachments(ctx *context.Context) {
issue := GetActionIssue(ctx)
- var attachments = make([]*api.Attachment, len(issue.Attachments))
+ attachments := make([]*api.Attachment, len(issue.Attachments))
for i := 0; i < len(issue.Attachments); i++ {
attachments[i] = convert.ToReleaseAttachment(issue.Attachments[i])
}
@@ -2522,7 +2518,7 @@ func GetCommentAttachments(ctx *context.Context) {
ctx.NotFoundOrServerError("GetCommentByID", models.IsErrCommentNotExist, err)
return
}
- var attachments = make([]*api.Attachment, 0)
+ attachments := make([]*api.Attachment, 0)
if comment.Type == models.CommentTypeComment {
if err := comment.LoadAttachments(); err != nil {
ctx.ServerError("LoadAttachments", err)
@@ -2667,7 +2663,7 @@ func handleTeamMentions(ctx *context.Context) {
var isAdmin bool
var err error
var teams []*models.Team
- var org = models.OrgFromUser(ctx.Repo.Owner)
+ org := models.OrgFromUser(ctx.Repo.Owner)
// Admin has super access.
if ctx.User.IsAdmin {
isAdmin = true
diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go
index 08eb98acb8..75951ca25b 100644
--- a/routers/web/repo/issue_content_history.go
+++ b/routers/web/repo/issue_content_history.go
@@ -83,8 +83,8 @@ func GetContentHistoryList(ctx *context.Context) {
// canSoftDeleteContentHistory checks whether current user can soft-delete a history revision
// Admins or owners can always delete history revisions. Normal users can only delete own history revisions.
func canSoftDeleteContentHistory(ctx *context.Context, issue *models.Issue, comment *models.Comment,
- history *issuesModel.ContentHistory) bool {
-
+ history *issuesModel.ContentHistory,
+) bool {
canSoftDelete := false
if ctx.Repo.IsOwner() {
canSoftDelete = true
@@ -103,7 +103,7 @@ func canSoftDeleteContentHistory(ctx *context.Context, issue *models.Issue, comm
return canSoftDelete
}
-//GetContentHistoryDetail get detail
+// GetContentHistoryDetail get detail
func GetContentHistoryDetail(ctx *context.Context) {
issue := GetActionIssue(ctx)
if issue == nil {
@@ -169,7 +169,7 @@ func GetContentHistoryDetail(ctx *context.Context) {
})
}
-//SoftDeleteContentHistory soft delete
+// SoftDeleteContentHistory soft delete
func SoftDeleteContentHistory(ctx *context.Context) {
issue := GetActionIssue(ctx)
if issue == nil {
diff --git a/routers/web/repo/issue_lock.go b/routers/web/repo/issue_lock.go
index 36894b4be3..103b60c65d 100644
--- a/routers/web/repo/issue_lock.go
+++ b/routers/web/repo/issue_lock.go
@@ -48,7 +48,6 @@ func LockIssue(ctx *context.Context) {
// UnlockIssue unlocks a previously locked issue.
func UnlockIssue(ctx *context.Context) {
-
issue := GetActionIssue(ctx)
if ctx.Written() {
return
diff --git a/routers/web/repo/issue_test.go b/routers/web/repo/issue_test.go
index b8862cf43d..debd2a8a3c 100644
--- a/routers/web/repo/issue_test.go
+++ b/routers/web/repo/issue_test.go
@@ -13,7 +13,7 @@ import (
)
func TestCombineLabelComments(t *testing.T) {
- var kases = []struct {
+ kases := []struct {
name string
beforeCombined []*models.Comment
afterCombined []*models.Comment
@@ -366,7 +366,7 @@ func TestCombineLabelComments(t *testing.T) {
for _, kase := range kases {
t.Run(kase.name, func(t *testing.T) {
- var issue = models.Issue{
+ issue := models.Issue{
Comments: kase.beforeCombined,
}
combineLabelComments(&issue)
diff --git a/routers/web/repo/lfs.go b/routers/web/repo/lfs.go
index 6b5e1dd624..2cb4330c08 100644
--- a/routers/web/repo/lfs.go
+++ b/routers/web/repo/lfs.go
@@ -305,7 +305,7 @@ func LFSFileGet(ctx *context.Context) {
var output bytes.Buffer
lines := strings.Split(escapedContent.String(), "\n")
- //Remove blank line at the end of file
+ // Remove blank line at the end of file
if len(lines) > 0 && lines[len(lines)-1] == "" {
lines = lines[:len(lines)-1]
}
@@ -536,7 +536,7 @@ func LFSAutoAssociate(ctx *context.Context) {
return
}
metas[i].Oid = oid[:idx]
- //metas[i].RepositoryID = ctx.Repo.Repository.ID
+ // metas[i].RepositoryID = ctx.Repo.Repository.ID
}
if err := models.LFSAutoAssociate(metas, ctx.User, ctx.Repo.Repository.ID); err != nil {
ctx.ServerError("LFSAutoAssociate", err)
diff --git a/routers/web/repo/migrate.go b/routers/web/repo/migrate.go
index 23e5b21b48..9a31d809d4 100644
--- a/routers/web/repo/migrate.go
+++ b/routers/web/repo/migrate.go
@@ -203,7 +203,7 @@ func MigratePost(ctx *context.Context) {
}
}
- var opts = migrations.MigrateOptions{
+ opts := migrations.MigrateOptions{
OriginalURL: form.CloneAddr,
GitServiceType: form.Service,
CloneAddr: remoteAddr,
diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go
index f6be8add0b..3836a00d04 100644
--- a/routers/web/repo/projects.go
+++ b/routers/web/repo/projects.go
@@ -531,7 +531,6 @@ func EditProjectBoard(ctx *context.Context) {
// SetDefaultProjectBoard set default board for uncategorized issues/pulls
func SetDefaultProjectBoard(ctx *context.Context) {
-
project, board := checkProjectBoardChangePermissions(ctx)
if ctx.Written() {
return
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index 517156863e..0aea66ca67 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -48,16 +48,14 @@ const (
pullRequestTemplateKey = "PullRequestTemplate"
)
-var (
- pullRequestTemplateCandidates = []string{
- "PULL_REQUEST_TEMPLATE.md",
- "pull_request_template.md",
- ".gitea/PULL_REQUEST_TEMPLATE.md",
- ".gitea/pull_request_template.md",
- ".github/PULL_REQUEST_TEMPLATE.md",
- ".github/pull_request_template.md",
- }
-)
+var pullRequestTemplateCandidates = []string{
+ "PULL_REQUEST_TEMPLATE.md",
+ "pull_request_template.md",
+ ".gitea/PULL_REQUEST_TEMPLATE.md",
+ ".gitea/pull_request_template.md",
+ ".github/PULL_REQUEST_TEMPLATE.md",
+ ".github/pull_request_template.md",
+}
func getRepository(ctx *context.Context, repoID int64) *repo_model.Repository {
repo, err := repo_model.GetRepositoryByID(repoID)
@@ -125,7 +123,7 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
}
}
- var traverseParentRepo = forkRepo
+ traverseParentRepo := forkRepo
for {
if ctx.User.ID == traverseParentRepo.OwnerID {
canForkToUser = false
@@ -195,7 +193,7 @@ func ForkPost(ctx *context.Context) {
}
var err error
- var traverseParentRepo = forkRepo
+ traverseParentRepo := forkRepo
for {
if ctxUser.ID == traverseParentRepo.OwnerID {
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), tplFork, &form)
@@ -1085,7 +1083,6 @@ func MergePullRequest(ctx *context.Context) {
}
func stopTimerIfAvailable(user *user_model.User, issue *models.Issue) error {
-
if models.StopwatchExists(user.ID, issue.ID) {
if err := models.CreateOrStopIssueStopwatch(user, issue); err != nil {
return err
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go
index 13623e15ef..4f58ac9546 100644
--- a/routers/web/repo/release.go
+++ b/routers/web/repo/release.go
@@ -481,7 +481,7 @@ func EditReleasePost(ctx *context.Context) {
const delPrefix = "attachment-del-"
const editPrefix = "attachment-edit-"
var addAttachmentUUIDs, delAttachmentUUIDs []string
- var editAttachments = make(map[string]string) // uuid -> new name
+ editAttachments := make(map[string]string) // uuid -> new name
if setting.Attachment.Enabled {
addAttachmentUUIDs = form.Files
for k, v := range ctx.Req.Form {
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 6bd16ff2b8..89ebef3a59 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -410,7 +410,7 @@ func Download(ctx *context.Context) {
}
var times int
- var t = time.NewTicker(time.Second * 1)
+ t := time.NewTicker(time.Second * 1)
defer t.Stop()
for {
@@ -447,7 +447,7 @@ func download(ctx *context.Context, archiveName string, archiver *repo_model.Rep
}
if setting.RepoArchive.ServeDirect {
- //If we have a signed url (S3, object storage), redirect to this directly.
+ // If we have a signed url (S3, object storage), redirect to this directly.
u, err := storage.RepoArchives.URL(rPath, downloadName)
if u != nil && err == nil {
ctx.Redirect(u.String())
@@ -455,7 +455,7 @@ func download(ctx *context.Context, archiveName string, archiver *repo_model.Rep
}
}
- //If we have matched and access to release or issue
+ // If we have matched and access to release or issue
fr, err := storage.RepoArchives.Open(rPath)
if err != nil {
ctx.ServerError("Open", err)
diff --git a/routers/web/repo/settings_test.go b/routers/web/repo/settings_test.go
index 5b62e1ed16..bd29eca195 100644
--- a/routers/web/repo/settings_test.go
+++ b/routers/web/repo/settings_test.go
@@ -100,7 +100,6 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
}
func TestCollaborationPost(t *testing.T) {
-
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
@@ -136,7 +135,6 @@ func TestCollaborationPost(t *testing.T) {
}
func TestCollaborationPost_InactiveUser(t *testing.T) {
-
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
@@ -160,7 +158,6 @@ func TestCollaborationPost_InactiveUser(t *testing.T) {
}
func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
-
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
@@ -202,7 +199,6 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
}
func TestCollaborationPost_NonExistentUser(t *testing.T) {
-
unittest.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
@@ -302,7 +298,6 @@ func TestAddTeamPost_NotAllowed(t *testing.T) {
assert.False(t, team.HasRepository(re.ID))
assert.EqualValues(t, http.StatusFound, ctx.Resp.Status())
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
-
}
func TestAddTeamPost_AddTeamTwice(t *testing.T) {
diff --git a/routers/web/repo/topic.go b/routers/web/repo/topic.go
index 810b241e28..a6a7ac6c8e 100644
--- a/routers/web/repo/topic.go
+++ b/routers/web/repo/topic.go
@@ -22,8 +22,8 @@ func TopicsPost(ctx *context.Context) {
return
}
- var topics = make([]string, 0)
- var topicsStr = ctx.FormTrim("topics")
+ topics := make([]string, 0)
+ topicsStr := ctx.FormTrim("topics")
if len(topicsStr) > 0 {
topics = strings.Split(topicsStr, ",")
}
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index e8c02b64b8..150ace212b 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -77,7 +77,7 @@ func getReadmeFileFromPath(commit *git.Commit, treePath string) (*namedBlob, err
}
var readmeFiles [4]*namedBlob
- var exts = []string{".md", ".txt", ""} // sorted by priority
+ exts := []string{".md", ".txt", ""} // sorted by priority
for _, entry := range entries {
if entry.IsDir() {
continue
@@ -150,7 +150,7 @@ func renderDirectory(ctx *context.Context, treeLink string) {
// strictly match an extension
var readmeFiles [4]*namedBlob
var docsEntries [3]*git.TreeEntry
- var exts = []string{".md", ".txt", ""} // sorted by priority
+ exts := []string{".md", ".txt", ""} // sorted by priority
for _, entry := range entries {
if entry.IsDir() {
lowerName := strings.ToLower(entry.Name())
@@ -368,7 +368,6 @@ func renderDirectory(ctx *context.Context, treeLink string) {
ctx.Data["CanAddFile"] = !ctx.Repo.Repository.IsArchived
ctx.Data["CanUploadFile"] = setting.Repository.Upload.Enabled && !ctx.Repo.Repository.IsArchived
}
-
}
func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink string) {
@@ -399,7 +398,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
isDisplayingSource := ctx.FormString("display") == "source"
isDisplayingRendered := !isDisplayingSource
- //Check for LFS meta file
+ // Check for LFS meta file
if isTextFile && setting.LFS.StartServer {
pointer, _ := lfs.ReadPointerFromBuffer(buf)
if pointer.IsValid() {
diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go
index e57aa5ec29..633458081f 100644
--- a/routers/web/repo/wiki.go
+++ b/routers/web/repo/wiki.go
@@ -191,7 +191,7 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
ctx.Data["title"] = pageName
ctx.Data["RequireHighlightJS"] = true
- //lookup filename in wiki - get filecontent, gitTree entry , real filename
+ // lookup filename in wiki - get filecontent, gitTree entry , real filename
data, entry, pageFilename, noEntry := wikiContentsByName(ctx, commit, pageName)
if noEntry {
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/?action=_pages")
@@ -219,7 +219,7 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
return nil, nil
}
- var rctx = &markup.RenderContext{
+ rctx := &markup.RenderContext{
Ctx: ctx,
URLPrefix: ctx.Repo.RepoLink,
Metas: ctx.Repo.Repository.ComposeDocumentMetas(),
@@ -291,7 +291,7 @@ func renderRevisionPage(ctx *context.Context) (*git.Repository, *git.TreeEntry)
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
- //lookup filename in wiki - get filecontent, gitTree entry , real filename
+ // lookup filename in wiki - get filecontent, gitTree entry , real filename
data, entry, pageFilename, noEntry := wikiContentsByName(ctx, commit, pageName)
if noEntry {
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/?action=_pages")
@@ -365,7 +365,7 @@ func renderEditPage(ctx *context.Context) {
ctx.Data["title"] = pageName
ctx.Data["RequireHighlightJS"] = true
- //lookup filename in wiki - get filecontent, gitTree entry , real filename
+ // lookup filename in wiki - get filecontent, gitTree entry , real filename
data, entry, _, noEntry := wikiContentsByName(ctx, commit, pageName)
if noEntry {
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/?action=_pages")
diff --git a/routers/web/repo/wiki_test.go b/routers/web/repo/wiki_test.go
index 1bfda50d19..b19c628a9f 100644
--- a/routers/web/repo/wiki_test.go
+++ b/routers/web/repo/wiki_test.go
@@ -20,8 +20,10 @@ import (
"github.com/stretchr/testify/assert"
)
-const content = "Wiki contents for unit tests"
-const message = "Wiki commit message for unit tests"
+const (
+ content = "Wiki contents for unit tests"
+ message = "Wiki commit message for unit tests"
+)
func wikiEntry(t *testing.T, repo *repo_model.Repository, wikiName string) *git.TreeEntry {
wikiRepo, err := git.OpenRepository(repo.WikiPath())
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index 04459573af..13fa9bd8c4 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -197,7 +197,7 @@ func Milestones(ctx *context.Context) {
if issueReposQueryPattern.MatchString(reposQuery) {
// remove "[" and "]" from string
reposQuery = reposQuery[1 : len(reposQuery)-1]
- //for each ID (delimiter ",") add to int to repoIDs
+ // for each ID (delimiter ",") add to int to repoIDs
for _, rID := range strings.Split(reposQuery, ",") {
// Ensure nonempty string entries
@@ -350,7 +350,6 @@ func Issues(ctx *context.Context) {
var issueReposQueryPattern = regexp.MustCompile(`^\[\d+(,\d+)*,?\]$`)
func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
-
// ----------------------------------------------------
// Determine user; can be either user or organization.
// Return with NotFound or ServerError if unsuccessful.
@@ -586,8 +585,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
ctx.Data["IsShowClosed"] = isShowClosed
- ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] =
- issue_service.GetRefEndNamesAndURLs(issues, ctx.FormString("RepoLink"))
+ ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] = issue_service.GetRefEndNamesAndURLs(issues, ctx.FormString("RepoLink"))
ctx.Data["Issues"] = issues
@@ -661,7 +659,7 @@ func getRepoIDs(reposQuery string) []int64 {
var repoIDs []int64
// remove "[" and "]" from string
reposQuery = reposQuery[1 : len(reposQuery)-1]
- //for each ID (delimiter ",") add to int to repoIDs
+ // for each ID (delimiter ",") add to int to repoIDs
for _, rID := range strings.Split(reposQuery, ",") {
// Ensure nonempty string entries
if rID != "" && rID != "0" {
@@ -693,8 +691,8 @@ func issueIDsFromSearch(ctxUser *user_model.User, keyword string, opts *models.I
}
func loadRepoByIDs(ctxUser *user_model.User, issueCountByRepo map[int64]int64, unitType unit.Type) (map[int64]*repo_model.Repository, error) {
- var totalRes = make(map[int64]*repo_model.Repository, len(issueCountByRepo))
- var repoIDs = make([]int64, 0, 500)
+ totalRes := make(map[int64]*repo_model.Repository, len(issueCountByRepo))
+ repoIDs := make([]int64, 0, 500)
for id := range issueCountByRepo {
if id <= 0 {
continue
@@ -745,7 +743,7 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
if err != nil {
if asymkey_model.IsErrGPGKeyImportNotExist(err) {
failedEntitiesID = append(failedEntitiesID, k.KeyID)
- continue //Skip previous import without backup of imported armored key
+ continue // Skip previous import without backup of imported armored key
}
ctx.ServerError("ShowGPGKeys", err)
return
@@ -755,12 +753,12 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
var buf bytes.Buffer
headers := make(map[string]string)
- if len(failedEntitiesID) > 0 { //If some key need re-import to be exported
+ if len(failedEntitiesID) > 0 { // If some key need re-import to be exported
headers["Note"] = fmt.Sprintf("The keys with the following IDs couldn't be exported and need to be reuploaded %s", strings.Join(failedEntitiesID, ", "))
}
writer, _ := armor.Encode(&buf, "PGP PUBLIC KEY BLOCK", headers)
for _, e := range entities {
- err = e.Serialize(writer) //TODO find why key are exported with a different cipherTypeByte as original (should not be blocking but strange)
+ err = e.Serialize(writer) // TODO find why key are exported with a different cipherTypeByte as original (should not be blocking but strange)
if err != nil {
ctx.ServerError("ShowGPGKeys", err)
return
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index 40fc44ed14..86ecb7c02c 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -258,7 +258,8 @@ func Profile(ctx *context.Context) {
total = ctxUser.NumFollowing
case "activity":
- ctx.Data["Feeds"] = feed.RetrieveFeeds(ctx, models.GetFeedsOptions{RequestedUser: ctxUser,
+ ctx.Data["Feeds"] = feed.RetrieveFeeds(ctx, models.GetFeedsOptions{
+ RequestedUser: ctxUser,
Actor: ctx.User,
IncludePrivate: showPrivate,
OnlyPerformedBy: true,
diff --git a/routers/web/user/setting/account_test.go b/routers/web/user/setting/account_test.go
index cd5c77795e..a67d09e9ed 100644
--- a/routers/web/user/setting/account_test.go
+++ b/routers/web/user/setting/account_test.go
@@ -20,9 +20,9 @@ import (
func TestChangePassword(t *testing.T) {
oldPassword := "password"
setting.MinPasswordLength = 6
- var pcALL = []string{"lower", "upper", "digit", "spec"}
- var pcLUN = []string{"lower", "upper", "digit"}
- var pcLU = []string{"lower", "upper"}
+ pcALL := []string{"lower", "upper", "digit", "spec"}
+ pcLUN := []string{"lower", "upper", "digit"}
+ pcLU := []string{"lower", "upper"}
for _, req := range []struct {
OldPassword string
diff --git a/routers/web/user/setting/keys.go b/routers/web/user/setting/keys.go
index 26bbf7c195..f926c1f311 100644
--- a/routers/web/user/setting/keys.go
+++ b/routers/web/user/setting/keys.go
@@ -211,7 +211,6 @@ func KeysPost(ctx *context.Context) {
ctx.Flash.Warning("Function not implemented")
ctx.Redirect(setting.AppSubURL + "/user/settings/keys")
}
-
}
// DeleteKey response for delete user's SSH/GPG key
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index ab156b43fc..3a61f2f92a 100644
--- a/routers/web/user/setting/profile.go
+++ b/routers/web/user/setting/profile.go
@@ -415,5 +415,4 @@ func UpdateUserLang(ctx *context.Context) {
log.Trace("User settings updated: %s", ctx.User.Name)
ctx.Flash.Success(i18n.Tr(ctx.User.Language, "settings.update_language_success"))
ctx.Redirect(setting.AppSubURL + "/user/settings/appearance")
-
}
diff --git a/routers/web/web.go b/routers/web/web.go
index e934095b79..698f91b8ca 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -56,9 +56,9 @@ const (
func CorsHandler() func(next http.Handler) http.Handler {
if setting.CORSConfig.Enabled {
return cors.Handler(cors.Options{
- //Scheme: setting.CORSConfig.Scheme, // FIXME: the cors middleware needs scheme option
+ // Scheme: setting.CORSConfig.Scheme, // FIXME: the cors middleware needs scheme option
AllowedOrigins: setting.CORSConfig.AllowDomain,
- //setting.CORSConfig.AllowSubdomain // FIXME: the cors middleware needs allowSubdomain option
+ // setting.CORSConfig.AllowSubdomain // FIXME: the cors middleware needs allowSubdomain option
AllowedMethods: setting.CORSConfig.Methods,
AllowCredentials: setting.CORSConfig.AllowCredentials,
MaxAge: int(setting.CORSConfig.MaxAge.Seconds()),
@@ -459,7 +459,6 @@ func RegisterRoutes(m *web.Route) {
m.Post("/msteams/new", bindIgnErr(forms.NewMSTeamsHookForm{}), repo.MSTeamsHooksNewPost)
m.Post("/feishu/new", bindIgnErr(forms.NewFeishuHookForm{}), repo.FeishuHooksNewPost)
m.Post("/wechatwork/new", bindIgnErr(forms.NewWechatWorkHookForm{}), repo.WechatworkHooksNewPost)
-
})
m.Group("/auths", func() {
@@ -691,7 +690,6 @@ func RegisterRoutes(m *web.Route) {
m.Post("/{lid}/unlock", repo.LFSUnlock)
})
})
-
}, func(ctx *context.Context) {
ctx.Data["PageIsSettings"] = true
ctx.Data["LFSStartServer"] = setting.LFS.StartServer
@@ -818,7 +816,6 @@ func RegisterRoutes(m *web.Route) {
m.Post("/delete", repo.DeleteBranchPost)
m.Post("/restore", repo.RestoreBranchPost)
}, context.RepoMustNotBeArchived(), reqRepoCodeWriter, repo.MustBeNotEmpty)
-
}, reqSignIn, context.RepoAssignment, context.UnitTypes())
// Releases
@@ -857,7 +854,6 @@ func RegisterRoutes(m *web.Route) {
}
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
})
-
}, ignSignIn, context.RepoAssignment, context.UnitTypes(), reqRepoReleaseReader)
// to maintain compatibility with old attachments
@@ -1085,5 +1081,4 @@ func RegisterRoutes(m *web.Route) {
ctx := context.GetContext(req)
ctx.NotFound("", nil)
})
-
}