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.

103 lines
4.2 KiB

  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2019 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package structs
  6. // FileOptions options for all file APIs
  7. type FileOptions struct {
  8. // message (optional) for the commit of this file. if not supplied, a default message will be used
  9. Message string `json:"message"`
  10. // branch (optional) to base this file from. if not given, the default branch is used
  11. BranchName string `json:"branch"`
  12. // new_branch (optional) will make a new branch from `branch` before creating the file
  13. NewBranchName string `json:"new_branch"`
  14. // `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
  15. Author Identity `json:"author"`
  16. Committer Identity `json:"committer"`
  17. }
  18. // CreateFileOptions options for creating files
  19. // Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
  20. type CreateFileOptions struct {
  21. FileOptions
  22. // content must be base64 encoded
  23. // required: true
  24. Content string `json:"content"`
  25. }
  26. // DeleteFileOptions options for deleting files (used for other File structs below)
  27. // Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
  28. type DeleteFileOptions struct {
  29. FileOptions
  30. // sha is the SHA for the file that already exists
  31. // required: true
  32. SHA string `json:"sha" binding:"Required"`
  33. }
  34. // UpdateFileOptions options for updating files
  35. // Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
  36. type UpdateFileOptions struct {
  37. DeleteFileOptions
  38. // content must be base64 encoded
  39. // required: true
  40. Content string `json:"content"`
  41. // from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL
  42. FromPath string `json:"from_path" binding:"MaxSize(500)"`
  43. }
  44. // FileLinksResponse contains the links for a repo's file
  45. type FileLinksResponse struct {
  46. Self *string `json:"self"`
  47. GitURL *string `json:"git"`
  48. HTMLURL *string `json:"html"`
  49. }
  50. // ContentsResponse contains information about a repo's entry's (dir, file, symlink, submodule) metadata and content
  51. type ContentsResponse struct {
  52. Name string `json:"name"`
  53. Path string `json:"path"`
  54. SHA string `json:"sha"`
  55. // `type` will be `file`, `dir`, `symlink`, or `submodule`
  56. Type string `json:"type"`
  57. Size int64 `json:"size"`
  58. // `encoding` is populated when `type` is `file`, otherwise null
  59. Encoding *string `json:"encoding"`
  60. // `content` is populated when `type` is `file`, otherwise null
  61. Content *string `json:"content"`
  62. // `target` is populated when `type` is `symlink`, otherwise null
  63. Target *string `json:"target"`
  64. URL *string `json:"url"`
  65. HTMLURL *string `json:"html_url"`
  66. GitURL *string `json:"git_url"`
  67. DownloadURL *string `json:"download_url"`
  68. // `submodule_git_url` is populated when `type` is `submodule`, otherwise null
  69. SubmoduleGitURL *string `json:"submodule_git_url"`
  70. Links *FileLinksResponse `json:"_links"`
  71. }
  72. // FileCommitResponse contains information generated from a Git commit for a repo's file.
  73. type FileCommitResponse struct {
  74. CommitMeta
  75. HTMLURL string `json:"html_url"`
  76. Author *CommitUser `json:"author"`
  77. Committer *CommitUser `json:"committer"`
  78. Parents []*CommitMeta `json:"parents"`
  79. Message string `json:"message"`
  80. Tree *CommitMeta `json:"tree"`
  81. }
  82. // FileResponse contains information about a repo's file
  83. type FileResponse struct {
  84. Content *ContentsResponse `json:"content"`
  85. Commit *FileCommitResponse `json:"commit"`
  86. Verification *PayloadCommitVerification `json:"verification"`
  87. }
  88. // FileDeleteResponse contains information about a repo's file that was deleted
  89. type FileDeleteResponse struct {
  90. Content interface{} `json:"content"` // to be set to nil
  91. Commit *FileCommitResponse `json:"commit"`
  92. Verification *PayloadCommitVerification `json:"verification"`
  93. }