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