diff options
author | 6543 <6543@obermui.de> | 2022-01-20 18:46:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 18:46:10 +0100 |
commit | 54e9ee37a7a301dbe74d46fd3c87712e6120e9bf (patch) | |
tree | 1be12fb072625c1b896b9d72f7912b018aad502b /routers/web/repo | |
parent | 1d98d205f5825f40110e6628b61a97c91ac7f72d (diff) | |
download | gitea-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/web/repo')
-rw-r--r-- | routers/web/repo/attachment.go | 10 | ||||
-rw-r--r-- | routers/web/repo/blame.go | 6 | ||||
-rw-r--r-- | routers/web/repo/branch.go | 2 | ||||
-rw-r--r-- | routers/web/repo/compare.go | 9 | ||||
-rw-r--r-- | routers/web/repo/download.go | 2 | ||||
-rw-r--r-- | routers/web/repo/editor_test.go | 2 | ||||
-rw-r--r-- | routers/web/repo/http.go | 5 | ||||
-rw-r--r-- | routers/web/repo/issue.go | 32 | ||||
-rw-r--r-- | routers/web/repo/issue_content_history.go | 8 | ||||
-rw-r--r-- | routers/web/repo/issue_lock.go | 1 | ||||
-rw-r--r-- | routers/web/repo/issue_test.go | 4 | ||||
-rw-r--r-- | routers/web/repo/lfs.go | 4 | ||||
-rw-r--r-- | routers/web/repo/migrate.go | 2 | ||||
-rw-r--r-- | routers/web/repo/projects.go | 1 | ||||
-rw-r--r-- | routers/web/repo/pull.go | 23 | ||||
-rw-r--r-- | routers/web/repo/release.go | 2 | ||||
-rw-r--r-- | routers/web/repo/repo.go | 6 | ||||
-rw-r--r-- | routers/web/repo/settings_test.go | 5 | ||||
-rw-r--r-- | routers/web/repo/topic.go | 4 | ||||
-rw-r--r-- | routers/web/repo/view.go | 7 | ||||
-rw-r--r-- | routers/web/repo/wiki.go | 8 | ||||
-rw-r--r-- | routers/web/repo/wiki_test.go | 6 |
22 files changed, 68 insertions, 81 deletions
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()) |