Skip to content

Commit b675434

Browse files
committed
Revert "keep sure if assigneeIDs == nil -> do nothing"
-> go handle it itself preaty well This reverts commit e72d941.
1 parent 3139ccf commit b675434

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

routers/api/v1/repo/issue.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -344,24 +344,22 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
344344
return
345345
}
346346

347-
if assigneeIDs != nil {
348-
for _, aID := range assigneeIDs {
349-
assignee, err := models.GetUserByID(aID)
350-
if err != nil {
351-
ctx.Error(500, "GetUserByID", err)
352-
return
353-
}
354-
355-
// Check if the passed assignees is assignable
356-
valid, err := models.CanBeAssigned(assignee, ctx.Repo.Repository, false)
357-
if err != nil {
358-
ctx.Error(500, "canBeAssigned", err)
359-
return
360-
}
361-
if !valid {
362-
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: ctx.Repo.Repository.Name})
363-
return
364-
}
347+
// Check if the passed assignees is assignable
348+
for _, aID := range assigneeIDs {
349+
assignee, err := models.GetUserByID(aID)
350+
if err != nil {
351+
ctx.Error(500, "GetUserByID", err)
352+
return
353+
}
354+
355+
valid, err := models.CanBeAssigned(assignee, ctx.Repo.Repository, false)
356+
if err != nil {
357+
ctx.Error(500, "canBeAssigned", err)
358+
return
359+
}
360+
if !valid {
361+
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: ctx.Repo.Repository.Name})
362+
return
365363
}
366364
}
367365
} else {

routers/api/v1/repo/pull.go

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -286,25 +286,22 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
286286
}
287287
return
288288
}
289+
// Check if the passed assignees is assignable
290+
for _, aID := range assigneeIDs {
291+
assignee, err := models.GetUserByID(aID)
292+
if err != nil {
293+
ctx.Error(500, "GetUserByID", err)
294+
return
295+
}
289296

290-
if assigneeIDs != nil {
291-
for _, aID := range assigneeIDs {
292-
assignee, err := models.GetUserByID(aID)
293-
if err != nil {
294-
ctx.Error(500, "GetUserByID", err)
295-
return
296-
}
297-
298-
// Check if the passed assignees is assignable
299-
valid, err := models.CanBeAssigned(assignee, repo, true)
300-
if err != nil {
301-
ctx.Error(500, "canBeAssigned", err)
302-
return
303-
}
304-
if !valid {
305-
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: repo.Name})
306-
return
307-
}
297+
valid, err := models.CanBeAssigned(assignee, repo, true)
298+
if err != nil {
299+
ctx.Error(500, "canBeAssigned", err)
300+
return
301+
}
302+
if !valid {
303+
ctx.Error(422, "canBeAssigned", models.ErrUserDoesNotHaveAccessToRepo{UserID: aID, RepoName: repo.Name})
304+
return
308305
}
309306
}
310307

0 commit comments

Comments
 (0)