[API] Add ref to create/edit issue options & deprecated assignee (#13992)

* API: Add ref to create/edit issue options

* deprecate Assignee in favour of Assignees
This commit is contained in:
6543 2020-12-15 18:38:10 +00:00 committed by GitHub
parent 980b0df829
commit e2aa701812
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 6 deletions

View file

@ -50,8 +50,9 @@ type Issue struct {
Ref string `json:"ref"` Ref string `json:"ref"`
Labels []*Label `json:"labels"` Labels []*Label `json:"labels"`
Milestone *Milestone `json:"milestone"` Milestone *Milestone `json:"milestone"`
Assignee *User `json:"assignee"` // deprecated
Assignees []*User `json:"assignees"` Assignee *User `json:"assignee"`
Assignees []*User `json:"assignees"`
// Whether the issue is open or closed // Whether the issue is open or closed
// //
// type: string // type: string
@ -83,7 +84,8 @@ type CreateIssueOption struct {
// required:true // required:true
Title string `json:"title" binding:"Required"` Title string `json:"title" binding:"Required"`
Body string `json:"body"` Body string `json:"body"`
// username of assignee Ref string `json:"ref"`
// deprecated
Assignee string `json:"assignee"` Assignee string `json:"assignee"`
Assignees []string `json:"assignees"` Assignees []string `json:"assignees"`
// swagger:strfmt date-time // swagger:strfmt date-time
@ -97,8 +99,10 @@ type CreateIssueOption struct {
// EditIssueOption options for editing an issue // EditIssueOption options for editing an issue
type EditIssueOption struct { type EditIssueOption struct {
Title string `json:"title"` Title string `json:"title"`
Body *string `json:"body"` Body *string `json:"body"`
Ref *string `json:"ref"`
// deprecated
Assignee *string `json:"assignee"` Assignee *string `json:"assignee"`
Assignees []string `json:"assignees"` Assignees []string `json:"assignees"`
Milestone *int64 `json:"milestone"` Milestone *int64 `json:"milestone"`

View file

@ -486,6 +486,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
PosterID: ctx.User.ID, PosterID: ctx.User.ID,
Poster: ctx.User, Poster: ctx.User,
Content: form.Body, Content: form.Body,
Ref: form.Ref,
DeadlineUnix: deadlineUnix, DeadlineUnix: deadlineUnix,
} }
@ -625,6 +626,13 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
if form.Body != nil { if form.Body != nil {
issue.Content = *form.Body issue.Content = *form.Body
} }
if form.Ref != nil {
err = issue_service.ChangeIssueRef(issue, ctx.User, *form.Ref)
if err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateRef", err)
return
}
}
// Update or remove the deadline, only if set and allowed // Update or remove the deadline, only if set and allowed
if (form.Deadline != nil || form.RemoveDeadline != nil) && canWrite { if (form.Deadline != nil || form.RemoveDeadline != nil) && canWrite {

View file

@ -11937,7 +11937,7 @@
], ],
"properties": { "properties": {
"assignee": { "assignee": {
"description": "username of assignee", "description": "deprecated",
"type": "string", "type": "string",
"x-go-name": "Assignee" "x-go-name": "Assignee"
}, },
@ -11976,6 +11976,10 @@
"format": "int64", "format": "int64",
"x-go-name": "Milestone" "x-go-name": "Milestone"
}, },
"ref": {
"type": "string",
"x-go-name": "Ref"
},
"title": { "title": {
"type": "string", "type": "string",
"x-go-name": "Title" "x-go-name": "Title"
@ -12778,6 +12782,7 @@
"type": "object", "type": "object",
"properties": { "properties": {
"assignee": { "assignee": {
"description": "deprecated",
"type": "string", "type": "string",
"x-go-name": "Assignee" "x-go-name": "Assignee"
}, },
@ -12802,6 +12807,10 @@
"format": "int64", "format": "int64",
"x-go-name": "Milestone" "x-go-name": "Milestone"
}, },
"ref": {
"type": "string",
"x-go-name": "Ref"
},
"state": { "state": {
"type": "string", "type": "string",
"x-go-name": "State" "x-go-name": "State"