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.

repo.go 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. // MigrateRepoOption options for migrating a repository from an external service
  147. type MigrateRepoOption struct {
  148. // required: true
  149. CloneAddr string `json:"clone_addr" binding:"Required"`
  150. AuthUsername string `json:"auth_username"`
  151. AuthPassword string `json:"auth_password"`
  152. // required: true
  153. UID int `json:"uid" binding:"Required"`
  154. // required: true
  155. RepoName string `json:"repo_name" binding:"Required"`
  156. Mirror bool `json:"mirror"`
  157. Private bool `json:"private"`
  158. Description string `json:"description"`
  159. Wiki bool
  160. Issues bool
  161. Milestones bool
  162. Labels bool
  163. Releases bool
  164. Comments bool
  165. PullRequests bool
  166. MigrateToRepoID int64
  167. }