forked from forgejo/forgejo
format with gofumpt (#18184)
* gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
This commit is contained in:
parent
1d98d205f5
commit
54e9ee37a7
423 changed files with 1585 additions and 1758 deletions
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue