]> source.dussan.org Git - gitea.git/commitdiff
[API] Add ref to create/edit issue options & deprecated assignee (#13992)
author6543 <6543@obermui.de>
Tue, 15 Dec 2020 18:38:10 +0000 (18:38 +0000)
committerGitHub <noreply@github.com>
Tue, 15 Dec 2020 18:38:10 +0000 (19:38 +0100)
* API: Add ref to create/edit issue options

* deprecate Assignee in favour of Assignees

modules/structs/issue.go
routers/api/v1/repo/issue.go
templates/swagger/v1_json.tmpl

index 06ad2de3228410e4b6ecf8d32ba31663f9223f4b..d990af63b45a7599e2ef73296edf9a133357e54e 100644 (file)
@@ -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"`
index c58e0bb6ce51f10cc53216fa7d28eff7757a6e26..25153ad50773c4ef323855cd9e9826efc80c8ea9 100644 (file)
@@ -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 {
index e77651b15eed7d4a8c7d4427f29f696fc9728c83..6eb53a3d70e1825acb6e87a2e09e39e45742790d 100644 (file)
       ],
       "properties": {
         "assignee": {
-          "description": "username of assignee",
+          "description": "deprecated",
           "type": "string",
           "x-go-name": "Assignee"
         },
           "format": "int64",
           "x-go-name": "Milestone"
         },
+        "ref": {
+          "type": "string",
+          "x-go-name": "Ref"
+        },
         "title": {
           "type": "string",
           "x-go-name": "Title"
       "type": "object",
       "properties": {
         "assignee": {
+          "description": "deprecated",
           "type": "string",
           "x-go-name": "Assignee"
         },
           "format": "int64",
           "x-go-name": "Milestone"
         },
+        "ref": {
+          "type": "string",
+          "x-go-name": "Ref"
+        },
         "state": {
           "type": "string",
           "x-go-name": "State"