refactor(repo): remove contents types (inlined)
zhenyi committed
Deleted lib/repo/features/contents/types.rs lib/repo/features/contents/types.rs +0 −175
@@ -1,175 +0,0 @@
1use serde::{Deserialize, Serialize};
2use utoipa::{IntoParams, ToSchema};
3
4fn default_branch() -> Option<String> {
5 None
6}
7fn default_new_branch() -> Option<String> {
8 None
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
12pub struct GitIdentity {
13 pub name: String,
14 pub email: String,
15 pub date: Option<String>,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, Default)]
19pub struct CommitDateOptions {
20 pub author: Option<String>,
21 pub committer: Option<String>,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
25pub struct FileOptions {
26 pub message: Option<String>,
27 #[serde(default = "default_branch")]
28 pub branch: Option<String>,
29 #[serde(default = "default_new_branch")]
30 pub new_branch: Option<String>,
31 pub force_push: Option<bool>,
32 pub author: Option<GitIdentity>,
33 pub committer: Option<GitIdentity>,
34 pub dates: Option<CommitDateOptions>,
35 pub signoff: Option<bool>,
36}
37
38impl Default for FileOptions {
39 fn default() -> Self {
40 Self {
41 message: None,
42 branch: None,
43 new_branch: None,
44 force_push: None,
45 author: None,
46 committer: None,
47 dates: None,
48 signoff: None,
49 }
50 }
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
54pub struct FileLinksResponse {
55 #[serde(rename = "self")]
56 pub self_link: Option<String>,
57 pub git: Option<String>,
58 pub html: Option<String>,
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
62pub struct ContentsResponse {
63 pub name: String,
64 pub path: String,
65 pub sha: String,
66 pub last_commit_sha: Option<String>,
67 pub last_committer_date: Option<String>,
68 pub last_author_date: Option<String>,
69 pub last_commit_message: Option<String>,
70 #[serde(rename = "type")]
71 pub type_: String,
72 pub size: i64,
73 pub encoding: Option<String>,
74 pub content: Option<String>,
75 pub target: Option<String>,
76 pub url: Option<String>,
77 pub html_url: Option<String>,
78 pub git_url: Option<String>,
79 pub download_url: Option<String>,
80 pub submodule_git_url: Option<String>,
81 pub links: Option<FileLinksResponse>,
82 pub lfs_oid: Option<String>,
83 pub lfs_size: Option<i64>,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
87pub struct ContentsExtResponse {
88 pub file_contents: Option<ContentsResponse>,
89 pub dir_contents: Vec<ContentsResponse>,
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
93pub struct ContentsListResponse {
94 pub items: Vec<ContentsResponse>,
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
98pub struct CreateFileOption {
99 #[serde(flatten)]
100 pub opts: FileOptions,
101 pub content: String,
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
105pub struct UpdateFileOption {
106 #[serde(flatten)]
107 pub opts: FileOptions,
108 pub sha: Option<String>,
109 pub content: String,
110 pub from_path: Option<String>,
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
114pub struct DeleteFileOption {
115 #[serde(flatten)]
116 pub opts: FileOptions,
117 pub sha: String,
118}
119
120#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
121pub struct ChangeFileEntry {
122 pub operation: String,
123 pub path: String,
124 pub content: Option<String>,
125 pub sha: Option<String>,
126 pub from_path: Option<String>,
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
130pub struct ChangeFilesOptions {
131 #[serde(flatten)]
132 pub opts: FileOptions,
133 pub files: Vec<ChangeFileEntry>,
134}
135
136#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
137pub struct ApplyDiffPatchFileOptions {
138 #[serde(flatten)]
139 pub opts: FileOptions,
140 pub content: String,
141 pub sha: Option<String>,
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
145pub struct FileResponse {
146 pub content: Option<ContentsResponse>,
147 pub commit: Option<CommitSummary>,
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
151pub struct CommitSummary {
152 pub sha: String,
153 pub message: String,
154 pub author: Option<GitIdentity>,
155 pub committer: Option<GitIdentity>,
156 pub url: Option<String>,
157 pub html_url: Option<String>,
158}
159
160#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
161pub struct FilesResponse {
162 pub commit: Option<CommitSummary>,
163 pub files: Vec<ContentsResponse>,
164}
165
166#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
167pub struct ContentsQuery {
168 #[serde(rename = "ref")]
169 pub ref_: Option<String>,
170}
171
172#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
173pub struct GetFilesOptions {
174 pub files: Vec<String>,
175}