本站源代码
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

217 lines
9.0KB

  1. // Copyright 2014 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. "time"
  7. )
  8. // Permission represents a set of permissions
  9. type Permission struct {
  10. Admin bool `json:"admin"`
  11. Push bool `json:"push"`
  12. Pull bool `json:"pull"`
  13. }
  14. // InternalTracker represents settings for internal tracker
  15. // swagger:model
  16. type InternalTracker struct {
  17. // Enable time tracking (Built-in issue tracker)
  18. EnableTimeTracker bool `json:"enable_time_tracker"`
  19. // Let only contributors track time (Built-in issue tracker)
  20. AllowOnlyContributorsToTrackTime bool `json:"allow_only_contributors_to_track_time"`
  21. // Enable dependencies for issues and pull requests (Built-in issue tracker)
  22. EnableIssueDependencies bool `json:"enable_issue_dependencies"`
  23. }
  24. // ExternalTracker represents settings for external tracker
  25. // swagger:model
  26. type ExternalTracker struct {
  27. // URL of external issue tracker.
  28. ExternalTrackerURL string `json:"external_tracker_url"`
  29. // External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index.
  30. ExternalTrackerFormat string `json:"external_tracker_format"`
  31. // External Issue Tracker Number Format, either `numeric` or `alphanumeric`
  32. ExternalTrackerStyle string `json:"external_tracker_style"`
  33. }
  34. // ExternalWiki represents setting for external wiki
  35. // swagger:model
  36. type ExternalWiki struct {
  37. // URL of external wiki.
  38. ExternalWikiURL string `json:"external_wiki_url"`
  39. }
  40. // Repository represents a repository
  41. type Repository struct {
  42. ID int64 `json:"id"`
  43. Owner *User `json:"owner"`
  44. Name string `json:"name"`
  45. FullName string `json:"full_name"`
  46. Description string `json:"description"`
  47. Empty bool `json:"empty"`
  48. Private bool `json:"private"`
  49. Fork bool `json:"fork"`
  50. Parent *Repository `json:"parent"`
  51. Mirror bool `json:"mirror"`
  52. Size int `json:"size"`
  53. HTMLURL string `json:"html_url"`
  54. SSHURL string `json:"ssh_url"`
  55. CloneURL string `json:"clone_url"`
  56. OriginalURL string `json:"original_url"`
  57. Website string `json:"website"`
  58. Stars int `json:"stars_count"`
  59. Forks int `json:"forks_count"`
  60. Watchers int `json:"watchers_count"`
  61. OpenIssues int `json:"open_issues_count"`
  62. DefaultBranch string `json:"default_branch"`
  63. Archived bool `json:"archived"`
  64. // swagger:strfmt date-time
  65. Created time.Time `json:"created_at"`
  66. // swagger:strfmt date-time
  67. Updated time.Time `json:"updated_at"`
  68. Permissions *Permission `json:"permissions,omitempty"`
  69. HasIssues bool `json:"has_issues"`
  70. InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
  71. ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
  72. HasWiki bool `json:"has_wiki"`
  73. ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"`
  74. HasPullRequests bool `json:"has_pull_requests"`
  75. IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
  76. AllowMerge bool `json:"allow_merge_commits"`
  77. AllowRebase bool `json:"allow_rebase"`
  78. AllowRebaseMerge bool `json:"allow_rebase_explicit"`
  79. AllowSquash bool `json:"allow_squash_merge"`
  80. AvatarURL string `json:"avatar_url"`
  81. }
  82. // CreateRepoOption options when creating repository
  83. // swagger:model
  84. type CreateRepoOption struct {
  85. // Name of the repository to create
  86. //
  87. // required: true
  88. // unique: true
  89. Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
  90. // Description of the repository to create
  91. Description string `json:"description" binding:"MaxSize(255)"`
  92. // Whether the repository is private
  93. Private bool `json:"private"`
  94. // Issue Label set to use
  95. IssueLabels string `json:"issue_labels"`
  96. // Whether the repository should be auto-intialized?
  97. AutoInit bool `json:"auto_init"`
  98. // Gitignores to use
  99. Gitignores string `json:"gitignores"`
  100. // License to use
  101. License string `json:"license"`
  102. // Readme of the repository to create
  103. Readme string `json:"readme"`
  104. }
  105. // EditRepoOption options when editing a repository's properties
  106. // swagger:model
  107. type EditRepoOption struct {
  108. // name of the repository
  109. // unique: true
  110. Name *string `json:"name,omitempty" binding:"OmitEmpty;AlphaDashDot;MaxSize(100);"`
  111. // a short description of the repository.
  112. Description *string `json:"description,omitempty" binding:"MaxSize(255)"`
  113. // a URL with more information about the repository.
  114. Website *string `json:"website,omitempty" binding:"MaxSize(255)"`
  115. // either `true` to make the repository private or `false` to make it public.
  116. // Note: you will get a 422 error if the organization restricts changing repository visibility to organization
  117. // owners and a non-owner tries to change the value of private.
  118. Private *bool `json:"private,omitempty"`
  119. // either `true` to enable issues for this repository or `false` to disable them.
  120. HasIssues *bool `json:"has_issues,omitempty"`
  121. // set this structure to configure internal issue tracker (requires has_issues)
  122. InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
  123. // set this structure to use external issue tracker (requires has_issues)
  124. ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
  125. // either `true` to enable the wiki for this repository or `false` to disable it.
  126. HasWiki *bool `json:"has_wiki,omitempty"`
  127. // set this structure to use external wiki instead of internal (requires has_wiki)
  128. ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"`
  129. // sets the default branch for this repository.
  130. DefaultBranch *string `json:"default_branch,omitempty"`
  131. // either `true` to allow pull requests, or `false` to prevent pull request.
  132. HasPullRequests *bool `json:"has_pull_requests,omitempty"`
  133. // either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. `has_pull_requests` must be `true`.
  134. IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"`
  135. // either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `has_pull_requests` must be `true`.
  136. AllowMerge *bool `json:"allow_merge_commits,omitempty"`
  137. // either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. `has_pull_requests` must be `true`.
  138. AllowRebase *bool `json:"allow_rebase,omitempty"`
  139. // either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits. `has_pull_requests` must be `true`.
  140. AllowRebaseMerge *bool `json:"allow_rebase_explicit,omitempty"`
  141. // either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. `has_pull_requests` must be `true`.
  142. AllowSquash *bool `json:"allow_squash_merge,omitempty"`
  143. // set to `true` to archive this repository.
  144. Archived *bool `json:"archived,omitempty"`
  145. }
  146. // GitServiceType represents a git service
  147. type GitServiceType int
  148. // enumerate all GitServiceType
  149. const (
  150. NotMigrated GitServiceType = iota // 0 not migrated from external sites
  151. PlainGitService // 1 plain git service
  152. GithubService // 2 github.com
  153. GiteaService // 3 gitea service
  154. GitlabService // 4 gitlab service
  155. GogsService // 5 gogs service
  156. )
  157. // Name represents the service type's name
  158. // WARNNING: the name have to be equal to that on goth's library
  159. func (gt GitServiceType) Name() string {
  160. switch gt {
  161. case GithubService:
  162. return "github"
  163. case GiteaService:
  164. return "gitea"
  165. case GitlabService:
  166. return "gitlab"
  167. case GogsService:
  168. return "gogs"
  169. }
  170. return ""
  171. }
  172. var (
  173. // SupportedFullGitService represents all git services supported to migrate issues/labels/prs and etc.
  174. // TODO: add to this list after new git service added
  175. SupportedFullGitService = []GitServiceType{
  176. GithubService,
  177. }
  178. )
  179. // MigrateRepoOption options for migrating a repository from an external service
  180. type MigrateRepoOption struct {
  181. // required: true
  182. CloneAddr string `json:"clone_addr" binding:"Required"`
  183. AuthUsername string `json:"auth_username"`
  184. AuthPassword string `json:"auth_password"`
  185. // required: true
  186. UID int `json:"uid" binding:"Required"`
  187. // required: true
  188. RepoName string `json:"repo_name" binding:"Required"`
  189. Mirror bool `json:"mirror"`
  190. Private bool `json:"private"`
  191. Description string `json:"description"`
  192. OriginalURL string
  193. GitServiceType GitServiceType
  194. Wiki bool
  195. Issues bool
  196. Milestones bool
  197. Labels bool
  198. Releases bool
  199. Comments bool
  200. PullRequests bool
  201. MigrateToRepoID int64
  202. }
上海开阖软件有限公司 沪ICP备12045867号-1