Chunk header and debug lines
parent: tbd commit: 09583e4
1 | use ; |
2 | use FromStr; |
3 | |
4 | use ; |
5 | |
6 | use crate GiteratedObject; |
7 | |
8 | use ; |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | pub use *; |
15 | pub use *; |
16 | pub use *; |
17 | |
18 | /// A repository, defined by the instance it exists on along with |
19 | /// its owner and name. |
20 | /// |
21 | /// # Textual Format |
22 | /// A repository's textual reference is defined as: |
23 | /// |
24 | /// `{owner: User}/{name: String}@{instance: Instance}` |
25 | /// |
26 | /// # Examples |
27 | /// For the repository named `foo` owned by `barson:giterated.dev` on the instance |
28 | /// `giterated.dev`, the following [`Repository`] initialization would |
29 | /// be valid: |
30 | /// |
31 | /// ``` |
32 | //# use giterated_models::model::repository::Repository; |
33 | //# use giterated_models::model::instance::Instance; |
34 | //# use giterated_models::model::user::User; |
35 | /// let repository = Repository { |
36 | /// owner: User::from_str("barson:giterated.dev").unwrap(), |
37 | /// name: String::from("foo"), |
38 | /// instance: Instance::from_str("giterated.dev").unwrap() |
39 | /// }; |
40 | /// |
41 | /// // This is correct |
42 | /// assert_eq!(Repository::from_str("barson:giterated.dev/[email protected]").unwrap(), repository); |
43 | /// ``` |
44 | |
45 | |
46 | pub owner: User, |
47 | pub name: String, |
48 | /// Instance the repository is on |
49 | pub instance: Instance, |
50 | |
51 | |
52 | |
53 | |
54 | f.write_str |
55 | |
56 | |
57 | |
58 | |
59 | |
60 | "repository" |
61 | |
62 | |
63 | |
64 | Ok |
65 | |
66 | |
67 | |
68 | |
69 | type Error = RepositoryParseError; |
70 | |
71 | |
72 | Self from_str |
73 | |
74 | |
75 | |
76 | |
77 | type Err = RepositoryParseError; |
78 | |
79 | |
80 | let mut by_ampersand = s.split; |
81 | let mut path_split = by_ampersand.next .ok_or?.split; |
82 | |
83 | let instance = from_str |
84 | .map_err?; |
85 | let owner = from_str |
86 | .map_err?; |
87 | let name = path_split.next .ok_or?.to_string; |
88 | |
89 | Ok |
90 | instance, |
91 | owner, |
92 | name, |
93 | |
94 | |
95 | |
96 | |
97 | |
98 | |
99 | ; |
100 | |
101 | /// Visibility of the repository to the general eye |
102 | |
103 | |
104 | |
105 | Public, |
106 | Unlisted, |
107 | Private, |
108 | |
109 | |
110 | /// Implements [`Display`] for [`RepositoryVisiblity`] using [`Debug`] |
111 | |
112 | |
113 | write! |
114 | |
115 | |
116 | |
117 | |
118 | |
119 | /// Name of the repository |
120 | /// |
121 | /// This is different than the [`Repository`] name, |
122 | /// which may be a path. |
123 | pub name: String, |
124 | /// Owner of the Repository |
125 | pub owner: User, |
126 | /// Repository description |
127 | pub description: , |
128 | /// Repository visibility |
129 | pub visibility: Visibility, |
130 | /// Default branch of the repository |
131 | pub default_branch: DefaultBranch, |
132 | /// Last commit made to the repository |
133 | pub latest_commit: , |
134 | /// Revision of the displayed tree |
135 | pub tree_rev: , |
136 | /// Repository tree |
137 | pub tree: , |
138 | |
139 | |
140 | |
141 | |
142 | /// Content of the file |
143 | pub content: , |
144 | /// If the file is binary or not |
145 | pub binary: bool, |
146 | /// File size in bytes |
147 | pub size: usize, |
148 | |
149 | |
150 | |
151 | |
152 | /// "to" side of the diff commit |
153 | pub new_commit: Commit, |
154 | /// Total number of files changed |
155 | pub files_changed: usize, |
156 | /// Total number of insertions |
157 | pub insertions: usize, |
158 | /// Total number of deletions |
159 | pub deletions: usize, |
160 | /// List of changed files |
161 | pub files: , |
162 | |
163 | |
164 | /// Represents the type of change made to a [`RepositoryDiffFile`] |
165 | |
166 | |
167 | /// No changes |
168 | Unmodified, |
169 | /// Content changed between old and new |
170 | Modified, |
171 | /// Renamed between old and new |
172 | Renamed, |
173 | /// Copied from another old entry |
174 | Copied, |
175 | /// Ignored item in workdir |
176 | Ignored, |
177 | /// Untracked item in workdir |
178 | Untracked, |
179 | /// Type of file changed between old and new |
180 | Typechange, |
181 | /// File is unreadable |
182 | Unreadable, |
183 | /// File in the index is conflicted |
184 | Conflicted, |
185 | |
186 | |
187 | |
188 | |
189 | match status |
190 | => Self Unmodified, | Unmodified
191 | => Self Modified, | Modified
192 | => Self Renamed, | Renamed
193 | => Self Copied, | Copied
194 | => Self Ignored, | Ignored
195 | => Self Untracked, | Untracked
196 | => Self Typechange, | Typechange
197 | => Self Unreadable, | Unreadable
198 | => Self Conflicted, | Conflicted
199 | _ => unreachable!, |
200 | |
201 | |
202 | |
203 | |
204 | /// Represents a single file of a diff |
205 | |
206 | |
207 | /// The type of change made to this file |
208 | pub status: RepositoryDiffFileStatus, |
209 | /// "From" side of the diff, can be nonexistent if file for example got added for the first time |
210 | pub old_file_info: , |
211 | /// "To" side of the diff, can be nonexistent if file got removed |
212 | pub new_file_info: , |
213 | /// Individual chunks of changes in this file |
214 | pub chunks: , |
215 | |
216 | |
217 | /// Represents one side of a file diff |
218 | |
219 | |
220 | /// ID of the file |
221 | pub id: String, |
222 | /// Path of the entry relative to the working directory of the repository |
223 | pub path: String, |
224 | /// Size in bytes |
225 | pub size: u64, |
226 | /// If the file is binary or not |
227 | pub binary: bool, |
228 | |
229 | |
230 | /// Represents a single chunk of a file diff |
231 | |
232 | |
233 | /// Header of the chunk |
234 | pub header: , |
235 | /// Starting line number of the old file |
236 | pub old_start: u32, |
237 | /// Number of lines in "from" side of this chunk |
238 | pub old_lines: u32, |
239 | /// Starting line number of the new file |
240 | pub new_start: u32, |
241 | /// Number of lines in "to" side of this chunk |
242 | pub new_lines: u32, |
243 | /// Lines of the chunk |
244 | pub lines: , |
245 | |
246 | |
247 | |
248 | |
249 | Tree, |
250 | Blob, |
251 | |
252 | |
253 | /// Stored info for our tree entries |
254 | |
255 | |
256 | /// ID of the tree/blob |
257 | pub id: String, |
258 | /// Name of the tree/blob |
259 | pub name: String, |
260 | /// Type of the tree entry |
261 | pub object_type: RepositoryObjectType, |
262 | /// Git supplies us with the mode at all times, and people like it displayed. |
263 | pub mode: i32, |
264 | /// File size |
265 | pub size: , |
266 | /// Last commit made to the tree/blob |
267 | pub last_commit: , |
268 | |
269 | |
270 | |
271 | // I love you Emilia <3 |
272 | |
273 | Self |
274 | id: id.to_string, |
275 | name: name.to_string, |
276 | object_type, |
277 | mode, |
278 | size: None, |
279 | last_commit: None, |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | |
286 | pub tree_entry: RepositoryTreeEntry, |
287 | pub commit: Commit, |
288 | |
289 | |
290 | /// Info about a git commit |
291 | |
292 | |
293 | /// Unique commit ID |
294 | pub oid: String, |
295 | /// Shortened abbreviated OID |
296 | /// This starts at the git config's "core.abbrev" length (default 7 characters) and |
297 | /// iteratively extends to a longer string if that length is ambiguous. The |
298 | /// result will be unambiguous (at least until new objects are added to the repository). |
299 | pub short_oid: String, |
300 | /// First paragraph of the full message |
301 | pub summary: , |
302 | /// Everything in the full message apart from the first paragraph |
303 | pub body: , |
304 | /// All commit id's of the parents of this commit |
305 | pub parents: , |
306 | /// Who created the commit |
307 | pub author: CommitSignature, |
308 | /// Who committed the commit |
309 | pub committer: CommitSignature, |
310 | /// Time when the commit happened |
311 | pub time: NaiveDateTime, |
312 | |
313 | |
314 | /// Gets all info from [`git2::Commit`] for easy use |
315 | |
316 | |
317 | Self |
318 | oid: commit.id .to_string, |
319 | // This shouldn't ever fail, as we already know the object has an oid. |
320 | short_oid: commit |
321 | .as_object |
322 | .short_id |
323 | .unwrap |
324 | .as_str |
325 | .unwrap |
326 | .to_string, |
327 | summary: commit.summary .map, |
328 | body: commit.body .map, |
329 | parents: commit |
330 | .parents |
331 | .map |
332 | ., |
333 | author: commit.author .into, |
334 | committer: commit.committer .into, |
335 | time: from_timestamp_opt .unwrap, |
336 | |
337 | |
338 | |
339 | |
340 | /// Git commit signature |
341 | |
342 | |
343 | pub name: , |
344 | pub email: , |
345 | pub time: NaiveDateTime, |
346 | |
347 | |
348 | /// Converts the signature from git2 into something usable without explicit lifetimes. |
349 | |
350 | |
351 | Self |
352 | name: signature.name .map, |
353 | email: signature.email .map, |
354 | time: from_timestamp_opt .unwrap, |
355 | |
356 | |
357 | |
358 | |
359 | |
360 | |
361 | pub repository: Repository, |
362 | pub owner: User, |
363 | pub visibility: RepositoryVisibility, |
364 | pub description: , |
365 | pub last_commit: , |
366 | |
367 | |
368 | |
369 | |
370 | pub name: String, |
371 | pub color: String, |
372 | |
373 | |
374 | |
375 | |
376 | pub author: User, |
377 | pub id: u64, |
378 | pub title: String, |
379 | pub contents: String, |
380 | pub labels: , |
381 | |
382 |