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 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. // Repository represents a repository
  15. type Repository struct {
  16. ID int64 `json:"id"`
  17. Owner *User `json:"owner"`
  18. Name string `json:"name"`
  19. FullName string `json:"full_name"`
  20. Description string `json:"description"`
  21. Empty bool `json:"empty"`
  22. Private bool `json:"private"`
  23. Fork bool `json:"fork"`
  24. Parent *Repository `json:"parent"`
  25. Mirror bool `json:"mirror"`
  26. Size int `json:"size"`
  27. HTMLURL string `json:"html_url"`
  28. SSHURL string `json:"ssh_url"`
  29. CloneURL string `json:"clone_url"`
  30. OriginalURL string `json:"original_url"`
  31. Website string `json:"website"`
  32. Stars int `json:"stars_count"`
  33. Forks int `json:"forks_count"`
  34. Watchers int `json:"watchers_count"`
  35. OpenIssues int `json:"open_issues_count"`
  36. DefaultBranch string `json:"default_branch"`
  37. Archived bool `json:"archived"`
  38. // swagger:strfmt date-time
  39. Created time.Time `json:"created_at"`
  40. // swagger:strfmt date-time
  41. Updated time.Time `json:"updated_at"`
  42. Permissions *Permission `json:"permissions,omitempty"`
  43. HasIssues bool `json:"has_issues"`
  44. HasWiki bool `json:"has_wiki"`
  45. HasPullRequests bool `json:"has_pull_requests"`
  46. IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
  47. AllowMerge bool `json:"allow_merge_commits"`
  48. AllowRebase bool `json:"allow_rebase"`
  49. AllowRebaseMerge bool `json:"allow_rebase_explicit"`
  50. AllowSquash bool `json:"allow_squash_merge"`
  51. AvatarURL string `json:"avatar_url"`
  52. }
  53. // CreateRepoOption options when creating repository
  54. // swagger:model
  55. type CreateRepoOption struct {
  56. // Name of the repository to create
  57. //
  58. // required: true
  59. // unique: true
  60. Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
  61. // Description of the repository to create
  62. Description string `json:"description" binding:"MaxSize(255)"`
  63. // Whether the repository is private
  64. Private bool `json:"private"`
  65. // Whether the repository should be auto-intialized?
  66. AutoInit bool `json:"auto_init"`
  67. // Gitignores to use
  68. Gitignores string `json:"gitignores"`
  69. // License to use
  70. License string `json:"license"`
  71. // Readme of the repository to create
  72. Readme string `json:"readme"`
  73. }
  74. // EditRepoOption options when editing a repository's properties
  75. // swagger:model
  76. type EditRepoOption struct {
  77. // name of the repository
  78. // unique: true
  79. Name *string `json:"name,omitempty" binding:"OmitEmpty;AlphaDashDot;MaxSize(100);"`
  80. // a short description of the repository.
  81. Description *string `json:"description,omitempty" binding:"MaxSize(255)"`
  82. // a URL with more information about the repository.
  83. Website *string `json:"website,omitempty" binding:"MaxSize(255)"`
  84. // either `true` to make the repository private or `false` to make it public.
  85. // Note: you will get a 422 error if the organization restricts changing repository visibility to organization
  86. // owners and a non-owner tries to change the value of private.
  87. Private *bool `json:"private,omitempty"`
  88. // either `true` to enable issues for this repository or `false` to disable them.
  89. HasIssues *bool `json:"has_issues,omitempty"`
  90. // either `true` to enable the wiki for this repository or `false` to disable it.
  91. HasWiki *bool `json:"has_wiki,omitempty"`
  92. // sets the default branch for this repository.
  93. DefaultBranch *string `json:"default_branch,omitempty"`
  94. // either `true` to allow pull requests, or `false` to prevent pull request.
  95. HasPullRequests *bool `json:"has_pull_requests,omitempty"`
  96. // either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. `has_pull_requests` must be `true`.
  97. IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"`
  98. // 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`.
  99. AllowMerge *bool `json:"allow_merge_commits,omitempty"`
  100. // either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. `has_pull_requests` must be `true`.
  101. AllowRebase *bool `json:"allow_rebase,omitempty"`
  102. // 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`.
  103. AllowRebaseMerge *bool `json:"allow_rebase_explicit,omitempty"`
  104. // either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. `has_pull_requests` must be `true`.
  105. AllowSquash *bool `json:"allow_squash_merge,omitempty"`
  106. // set to `true` to archive this repository.
  107. Archived *bool `json:"archived,omitempty"`
  108. }
  109. // MigrateRepoOption options for migrating a repository from an external service
  110. type MigrateRepoOption struct {
  111. // required: true
  112. CloneAddr string `json:"clone_addr" binding:"Required"`
  113. AuthUsername string `json:"auth_username"`
  114. AuthPassword string `json:"auth_password"`
  115. // required: true
  116. UID int `json:"uid" binding:"Required"`
  117. // required: true
  118. RepoName string `json:"repo_name" binding:"Required"`
  119. Mirror bool `json:"mirror"`
  120. Private bool `json:"private"`
  121. Description string `json:"description"`
  122. }