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.

80 lines
2.7 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 string `json:"message" binding:"Required"`
  9. BranchName string `json:"branch"`
  10. NewBranchName string `json:"new_branch"`
  11. Author Identity `json:"author"`
  12. Committer Identity `json:"committer"`
  13. }
  14. // CreateFileOptions options for creating files
  15. type CreateFileOptions struct {
  16. FileOptions
  17. Content string `json:"content"`
  18. }
  19. // DeleteFileOptions options for deleting files (used for other File structs below)
  20. type DeleteFileOptions struct {
  21. FileOptions
  22. SHA string `json:"sha" binding:"Required"`
  23. }
  24. // UpdateFileOptions options for updating files
  25. type UpdateFileOptions struct {
  26. DeleteFileOptions
  27. Content string `json:"content"`
  28. FromPath string `json:"from_path" binding:"MaxSize(500)"`
  29. }
  30. // FileLinksResponse contains the links for a repo's file
  31. type FileLinksResponse struct {
  32. Self string `json:"url"`
  33. GitURL string `json:"git_url"`
  34. HTMLURL string `json:"html_url"`
  35. }
  36. // FileContentResponse contains information about a repo's file stats and content
  37. type FileContentResponse struct {
  38. Name string `json:"name"`
  39. Path string `json:"path"`
  40. SHA string `json:"sha"`
  41. Size int64 `json:"size"`
  42. URL string `json:"url"`
  43. HTMLURL string `json:"html_url"`
  44. GitURL string `json:"git_url"`
  45. DownloadURL string `json:"download_url"`
  46. Type string `json:"type"`
  47. Links *FileLinksResponse `json:"_links"`
  48. }
  49. // FileCommitResponse contains information generated from a Git commit for a repo's file.
  50. type FileCommitResponse struct {
  51. CommitMeta
  52. HTMLURL string `json:"html_url"`
  53. Author *CommitUser `json:"author"`
  54. Committer *CommitUser `json:"committer"`
  55. Parents []*CommitMeta `json:"parents"`
  56. Message string `json:"message"`
  57. Tree *CommitMeta `json:"tree"`
  58. }
  59. // FileResponse contains information about a repo's file
  60. type FileResponse struct {
  61. Content *FileContentResponse `json:"content"`
  62. Commit *FileCommitResponse `json:"commit"`
  63. Verification *PayloadCommitVerification `json:"verification"`
  64. }
  65. // FileDeleteResponse contains information about a repo's file that was deleted
  66. type FileDeleteResponse struct {
  67. Content interface{} `json:"content"` // to be set to nil
  68. Commit *FileCommitResponse `json:"commit"`
  69. Verification *PayloadCommitVerification `json:"verification"`
  70. }