summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-12-15 18:38:10 +0000
committerGitHub <noreply@github.com>2020-12-15 19:38:10 +0100
commite2aa7018128bc00c079820174baced9c8d6908c1 (patch)
tree5f2d3e3d195f8a0597c02ab0e0ba352583980eed
parent980b0df8296cdec3692482c3efdbfa68036a1114 (diff)
downloadgitea-e2aa7018128bc00c079820174baced9c8d6908c1.tar.gz
gitea-e2aa7018128bc00c079820174baced9c8d6908c1.zip
[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
-rw-r--r--modules/structs/issue.go14
-rw-r--r--routers/api/v1/repo/issue.go8
-rw-r--r--templates/swagger/v1_json.tmpl11
3 files changed, 27 insertions, 6 deletions
diff --git a/modules/structs/issue.go b/modules/structs/issue.go
index 06ad2de322..d990af63b4 100644
--- a/modules/structs/issue.go
+++ b/modules/structs/issue.go
@@ -50,8 +50,9 @@ type Issue struct {
Ref string `json:"ref"`
Labels []*Label `json:"labels"`
Milestone *Milestone `json:"milestone"`
- Assignee *User `json:"assignee"`
- Assignees []*User `json:"assignees"`
+ // deprecated
+ Assignee *User `json:"assignee"`
+ Assignees []*User `json:"assignees"`
// Whether the issue is open or closed
//
// type: string
@@ -83,7 +84,8 @@ type CreateIssueOption struct {
// required:true
Title string `json:"title" binding:"Required"`
Body string `json:"body"`
- // username of assignee
+ Ref string `json:"ref"`
+ // deprecated
Assignee string `json:"assignee"`
Assignees []string `json:"assignees"`
// swagger:strfmt date-time
@@ -97,8 +99,10 @@ type CreateIssueOption struct {
// EditIssueOption options for editing an issue
type EditIssueOption struct {
- Title string `json:"title"`
- Body *string `json:"body"`
+ Title string `json:"title"`
+ Body *string `json:"body"`
+ Ref *string `json:"ref"`
+ // deprecated
Assignee *string `json:"assignee"`
Assignees []string `json:"assignees"`
Milestone *int64 `json:"milestone"`
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index c58e0bb6ce..25153ad507 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -486,6 +486,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
PosterID: ctx.User.ID,
Poster: ctx.User,
Content: form.Body,
+ Ref: form.Ref,
DeadlineUnix: deadlineUnix,
}
@@ -625,6 +626,13 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
if form.Body != nil {
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
if (form.Deadline != nil || form.RemoveDeadline != nil) && canWrite {
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index e77651b15e..6eb53a3d70 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -11937,7 +11937,7 @@
],
"properties": {
"assignee": {
- "description": "username of assignee",
+ "description": "deprecated",
"type": "string",
"x-go-name": "Assignee"
},
@@ -11976,6 +11976,10 @@
"format": "int64",
"x-go-name": "Milestone"
},
+ "ref": {
+ "type": "string",
+ "x-go-name": "Ref"
+ },
"title": {
"type": "string",
"x-go-name": "Title"
@@ -12778,6 +12782,7 @@
"type": "object",
"properties": {
"assignee": {
+ "description": "deprecated",
"type": "string",
"x-go-name": "Assignee"
},
@@ -12802,6 +12807,10 @@
"format": "int64",
"x-go-name": "Milestone"
},
+ "ref": {
+ "type": "string",
+ "x-go-name": "Ref"
+ },
"state": {
"type": "string",
"x-go-name": "State"