Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

repo_file.go 3.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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" binding:"Required"`
  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:"url"`
  47. GitURL string `json:"git_url"`
  48. HTMLURL string `json:"html_url"`
  49. }
  50. // FileContentResponse contains information about a repo's file stats and content
  51. type FileContentResponse struct {
  52. Name string `json:"name"`
  53. Path string `json:"path"`
  54. SHA string `json:"sha"`
  55. Size int64 `json:"size"`
  56. URL string `json:"url"`
  57. HTMLURL string `json:"html_url"`
  58. GitURL string `json:"git_url"`
  59. DownloadURL string `json:"download_url"`
  60. Type string `json:"type"`
  61. Links *FileLinksResponse `json:"_links"`
  62. }
  63. // FileCommitResponse contains information generated from a Git commit for a repo's file.
  64. type FileCommitResponse struct {
  65. CommitMeta
  66. HTMLURL string `json:"html_url"`
  67. Author *CommitUser `json:"author"`
  68. Committer *CommitUser `json:"committer"`
  69. Parents []*CommitMeta `json:"parents"`
  70. Message string `json:"message"`
  71. Tree *CommitMeta `json:"tree"`
  72. }
  73. // FileResponse contains information about a repo's file
  74. type FileResponse struct {
  75. Content *FileContentResponse `json:"content"`
  76. Commit *FileCommitResponse `json:"commit"`
  77. Verification *PayloadCommitVerification `json:"verification"`
  78. }
  79. // FileDeleteResponse contains information about a repo's file that was deleted
  80. type FileDeleteResponse struct {
  81. Content interface{} `json:"content"` // to be set to nil
  82. Commit *FileCommitResponse `json:"commit"`
  83. Verification *PayloadCommitVerification `json:"verification"`
  84. }