summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/repo')
-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
14 files changed, 20 insertions, 28 deletions
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 {