You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

issue.go 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package structs
  5. import (
  6. "strings"
  7. "time"
  8. )
  9. // StateType issue state type
  10. type StateType string
  11. const (
  12. // StateOpen pr is opend
  13. StateOpen StateType = "open"
  14. // StateClosed pr is closed
  15. StateClosed StateType = "closed"
  16. // StateAll is all
  17. StateAll StateType = "all"
  18. )
  19. // PullRequestMeta PR info if an issue is a PR
  20. type PullRequestMeta struct {
  21. HasMerged bool `json:"merged"`
  22. Merged *time.Time `json:"merged_at"`
  23. }
  24. // RepositoryMeta basic repository information
  25. type RepositoryMeta struct {
  26. ID int64 `json:"id"`
  27. Name string `json:"name"`
  28. Owner string `json:"owner"`
  29. FullName string `json:"full_name"`
  30. }
  31. // Issue represents an issue in a repository
  32. // swagger:model
  33. type Issue struct {
  34. ID int64 `json:"id"`
  35. URL string `json:"url"`
  36. HTMLURL string `json:"html_url"`
  37. Index int64 `json:"number"`
  38. Poster *User `json:"user"`
  39. OriginalAuthor string `json:"original_author"`
  40. OriginalAuthorID int64 `json:"original_author_id"`
  41. Title string `json:"title"`
  42. Body string `json:"body"`
  43. Ref string `json:"ref"`
  44. Labels []*Label `json:"labels"`
  45. Milestone *Milestone `json:"milestone"`
  46. // deprecated
  47. Assignee *User `json:"assignee"`
  48. Assignees []*User `json:"assignees"`
  49. // Whether the issue is open or closed
  50. //
  51. // type: string
  52. // enum: open,closed
  53. State StateType `json:"state"`
  54. IsLocked bool `json:"is_locked"`
  55. Comments int `json:"comments"`
  56. // swagger:strfmt date-time
  57. Created time.Time `json:"created_at"`
  58. // swagger:strfmt date-time
  59. Updated time.Time `json:"updated_at"`
  60. // swagger:strfmt date-time
  61. Closed *time.Time `json:"closed_at"`
  62. // swagger:strfmt date-time
  63. Deadline *time.Time `json:"due_date"`
  64. PullRequest *PullRequestMeta `json:"pull_request"`
  65. Repo *RepositoryMeta `json:"repository"`
  66. }
  67. // CreateIssueOption options to create one issue
  68. type CreateIssueOption struct {
  69. // required:true
  70. Title string `json:"title" binding:"Required"`
  71. Body string `json:"body"`
  72. Ref string `json:"ref"`
  73. // deprecated
  74. Assignee string `json:"assignee"`
  75. Assignees []string `json:"assignees"`
  76. // swagger:strfmt date-time
  77. Deadline *time.Time `json:"due_date"`
  78. // milestone id
  79. Milestone int64 `json:"milestone"`
  80. // list of label ids
  81. Labels []int64 `json:"labels"`
  82. Closed bool `json:"closed"`
  83. }
  84. // EditIssueOption options for editing an issue
  85. type EditIssueOption struct {
  86. Title string `json:"title"`
  87. Body *string `json:"body"`
  88. Ref *string `json:"ref"`
  89. // deprecated
  90. Assignee *string `json:"assignee"`
  91. Assignees []string `json:"assignees"`
  92. Milestone *int64 `json:"milestone"`
  93. State *string `json:"state"`
  94. // swagger:strfmt date-time
  95. Deadline *time.Time `json:"due_date"`
  96. RemoveDeadline *bool `json:"unset_due_date"`
  97. }
  98. // EditDeadlineOption options for creating a deadline
  99. type EditDeadlineOption struct {
  100. // required:true
  101. // swagger:strfmt date-time
  102. Deadline *time.Time `json:"due_date"`
  103. }
  104. // IssueDeadline represents an issue deadline
  105. // swagger:model
  106. type IssueDeadline struct {
  107. // swagger:strfmt date-time
  108. Deadline *time.Time `json:"due_date"`
  109. }
  110. // IssueTemplate represents an issue template for a repository
  111. // swagger:model
  112. type IssueTemplate struct {
  113. Name string `json:"name" yaml:"name"`
  114. Title string `json:"title" yaml:"title"`
  115. About string `json:"about" yaml:"about"`
  116. Labels []string `json:"labels" yaml:"labels"`
  117. Content string `json:"content" yaml:"-"`
  118. FileName string `json:"file_name" yaml:"-"`
  119. }
  120. // Valid checks whether an IssueTemplate is considered valid, e.g. at least name and about
  121. func (it IssueTemplate) Valid() bool {
  122. return strings.TrimSpace(it.Name) != "" && strings.TrimSpace(it.About) != ""
  123. }