Change forwarding
parent: tbd commit: 2556801
1 | use ; |
2 | use FromStr; |
3 | |
4 | use ; |
5 | |
6 | use ; |
7 | |
8 | /// A repository, defined by the instance it exists on along with |
9 | /// its owner and name. |
10 | /// |
11 | /// # Textual Format |
12 | /// A repository's textual reference is defined as: |
13 | /// |
14 | /// `{owner: User}/{name: String}@{instance: Instance}` |
15 | /// |
16 | /// # Examples |
17 | /// For the repository named `foo` owned by `barson:giterated.dev` on the instance |
18 | /// `giterated.dev`, the following [`Repository`] initialization would |
19 | /// be valid: |
20 | /// |
21 | /// ``` |
22 | /// let repository = Repository { |
23 | /// owner: User::from_str("barson:giterated.dev").unwrap(), |
24 | /// name: String::from("foo"), |
25 | /// instance: Instance::from_str("giterated.dev").unwrap() |
26 | /// }; |
27 | /// |
28 | /// // This is correct |
29 | /// assert_eq!(Repository::from_str("barson:giterated.dev/[email protected]").unwrap(), repository); |
30 | /// ``` |
31 | |
32 | |
33 | pub owner: User, |
34 | pub name: String, |
35 | /// Instance the repository is on |
36 | pub instance: Instance, |
37 | |
38 | |
39 | |
40 | |
41 | format! |
42 | |
43 | |
44 | |
45 | |
46 | type Error = ; |
47 | |
48 | |
49 | Self from_str |
50 | |
51 | |
52 | |
53 | |
54 | type Err = ; |
55 | |
56 | |
57 | let mut by_ampersand = s.split; |
58 | let mut path_split = by_ampersand.next .unwrap .split; |
59 | |
60 | let instance = from_str .unwrap; |
61 | let owner = from_str .unwrap; |
62 | let name = path_split.next .unwrap .to_string; |
63 | |
64 | Ok |
65 | instance, |
66 | owner, |
67 | name, |
68 | |
69 | |
70 | |
71 | |
72 | /// Visibility of the repository to the general eye |
73 | |
74 | |
75 | |
76 | Public, |
77 | Unlisted, |
78 | Private, |
79 | |
80 | |
81 | /// Implements [`Display`] for [`RepositoryVisiblity`] using [`Debug`] |
82 | |
83 | |
84 | write! |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | /// Name of the repository |
91 | /// |
92 | /// This is different than the [`Repository`] name, |
93 | /// which may be a path. |
94 | pub name: String, |
95 | /// Owner of the Repository |
96 | pub owner: User, |
97 | /// Repository description |
98 | pub description: , |
99 | /// Repository visibility |
100 | pub visibility: RepositoryVisibility, |
101 | /// Default branch of the repository |
102 | pub default_branch: String, |
103 | /// Last commit made to the repository |
104 | pub latest_commit: , |
105 | /// Revision of the displayed tree |
106 | pub tree_rev: , |
107 | /// Repository tree |
108 | pub tree: , |
109 | |
110 | |
111 | |
112 | |
113 | Tree, |
114 | Blob, |
115 | |
116 | |
117 | /// Stored info for our tree entries |
118 | |
119 | |
120 | /// Name of the tree/blob |
121 | pub name: String, |
122 | /// Type of the tree entry |
123 | pub object_type: RepositoryObjectType, |
124 | /// Git supplies us with the mode at all times, and people like it displayed. |
125 | pub mode: i32, |
126 | /// File size |
127 | pub size: , |
128 | /// Last commit made to the tree/blob |
129 | pub last_commit: , |
130 | |
131 | |
132 | |
133 | // I love you Emilia <3 |
134 | |
135 | Self |
136 | name: name.to_string, |
137 | object_type, |
138 | mode, |
139 | size: None, |
140 | last_commit: None, |
141 | |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | pub tree_entry: RepositoryTreeEntry, |
148 | pub commit: Commit, |
149 | |
150 | |
151 | /// Info about a git commit |
152 | |
153 | |
154 | /// Unique commit ID |
155 | pub oid: String, |
156 | /// Shortened abbreviated OID |
157 | /// This starts at the git config's "core.abbrev" length (default 7 characters) and |
158 | /// iteratively extends to a longer string if that length is ambiguous. The |
159 | /// result will be unambiguous (at least until new objects are added to the repository). |
160 | pub short_oid: String, |
161 | /// Full commit message |
162 | pub message: , |
163 | /// Who created the commit |
164 | pub author: CommitSignature, |
165 | /// Who committed the commit |
166 | pub committer: CommitSignature, |
167 | /// Time when the commit happened |
168 | pub time: NaiveDateTime, |
169 | |
170 | |
171 | /// Gets all info from [`git2::Commit`] for easy use |
172 | |
173 | |
174 | Self |
175 | oid: commit.id .to_string, |
176 | // This shouldn't ever fail, as we already know the object has an oid. |
177 | short_oid: commit |
178 | .as_object |
179 | .short_id |
180 | .unwrap |
181 | .as_str |
182 | .unwrap |
183 | .to_string, |
184 | message: commit.message .map, |
185 | author: commit.author .into, |
186 | committer: commit.committer .into, |
187 | time: from_timestamp_opt .unwrap, |
188 | |
189 | |
190 | |
191 | |
192 | /// Git commit signature |
193 | |
194 | |
195 | pub name: , |
196 | pub email: , |
197 | pub time: NaiveDateTime, |
198 | |
199 | |
200 | /// Converts the signature from git2 into something usable without explicit lifetimes. |
201 | |
202 | |
203 | Self |
204 | name: signature.name .map, |
205 | email: signature.email .map, |
206 | time: from_timestamp_opt .unwrap, |
207 | |
208 | |
209 | |
210 | |
211 | |
212 | |
213 | pub repository: Repository, |
214 | pub owner: User, |
215 | pub visibility: RepositoryVisibility, |
216 | pub description: , |
217 | pub last_commit: , |
218 | |
219 |