Fixes
parent: tbd commit: 73a5af5
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 |
82 | .next |
83 | .ok_or_else? |
84 | .split; |
85 | |
86 | let instance = from_str |
87 | .map_err?; |
88 | let owner = from_str |
89 | .map_err?; |
90 | let name = path_split |
91 | .next |
92 | .ok_or_else? |
93 | .to_string; |
94 | |
95 | Ok |
96 | instance, |
97 | owner, |
98 | name, |
99 | |
100 | |
101 | |
102 | |
103 | |
104 | |
105 | ; |
106 | |
107 | /// Visibility of the repository to the general eye |
108 | |
109 | |
110 | |
111 | Public, |
112 | Unlisted, |
113 | Private, |
114 | |
115 | |
116 | /// Implements [`Display`] for [`RepositoryVisiblity`] using [`Debug`] |
117 | |
118 | |
119 | write! |
120 | |
121 | |
122 | |
123 | |
124 | |
125 | /// Name of the repository |
126 | /// |
127 | /// This is different than the [`Repository`] name, |
128 | /// which may be a path. |
129 | pub name: String, |
130 | /// Owner of the Repository |
131 | pub owner: User, |
132 | /// Repository description |
133 | pub description: , |
134 | /// Repository visibility |
135 | pub visibility: RepositoryVisibility, |
136 | /// Default branch of the repository |
137 | pub default_branch: String, |
138 | /// Last commit made to the repository |
139 | pub latest_commit: , |
140 | /// Revision of the displayed tree |
141 | pub tree_rev: , |
142 | /// Repository tree |
143 | pub tree: , |
144 | |
145 | |
146 | |
147 | |
148 | Tree, |
149 | Blob, |
150 | |
151 | |
152 | /// Stored info for our tree entries |
153 | |
154 | |
155 | /// Name of the tree/blob |
156 | pub name: String, |
157 | /// Type of the tree entry |
158 | pub object_type: RepositoryObjectType, |
159 | /// Git supplies us with the mode at all times, and people like it displayed. |
160 | pub mode: i32, |
161 | /// File size |
162 | pub size: , |
163 | /// Last commit made to the tree/blob |
164 | pub last_commit: , |
165 | |
166 | |
167 | |
168 | // I love you Emilia <3 |
169 | |
170 | Self |
171 | name: name.to_string, |
172 | object_type, |
173 | mode, |
174 | size: None, |
175 | last_commit: None, |
176 | |
177 | |
178 | |
179 | |
180 | |
181 | |
182 | pub tree_entry: RepositoryTreeEntry, |
183 | pub commit: Commit, |
184 | |
185 | |
186 | /// Info about a git commit |
187 | |
188 | |
189 | /// Unique commit ID |
190 | pub oid: String, |
191 | /// Shortened abbreviated OID |
192 | /// This starts at the git config's "core.abbrev" length (default 7 characters) and |
193 | /// iteratively extends to a longer string if that length is ambiguous. The |
194 | /// result will be unambiguous (at least until new objects are added to the repository). |
195 | pub short_oid: String, |
196 | /// Full commit message |
197 | pub message: , |
198 | /// Who created the commit |
199 | pub author: CommitSignature, |
200 | /// Who committed the commit |
201 | pub committer: CommitSignature, |
202 | /// Time when the commit happened |
203 | pub time: NaiveDateTime, |
204 | |
205 | |
206 | /// Gets all info from [`git2::Commit`] for easy use |
207 | |
208 | |
209 | Self |
210 | oid: commit.id .to_string, |
211 | // This shouldn't ever fail, as we already know the object has an oid. |
212 | short_oid: commit |
213 | .as_object |
214 | .short_id |
215 | .unwrap |
216 | .as_str |
217 | .unwrap |
218 | .to_string, |
219 | message: commit.message .map, |
220 | author: commit.author .into, |
221 | committer: commit.committer .into, |
222 | time: from_timestamp_opt .unwrap, |
223 | |
224 | |
225 | |
226 | |
227 | /// Git commit signature |
228 | |
229 | |
230 | pub name: , |
231 | pub email: , |
232 | pub time: NaiveDateTime, |
233 | |
234 | |
235 | /// Converts the signature from git2 into something usable without explicit lifetimes. |
236 | |
237 | |
238 | Self |
239 | name: signature.name .map, |
240 | email: signature.email .map, |
241 | time: from_timestamp_opt .unwrap, |
242 | |
243 | |
244 | |
245 | |
246 | |
247 | |
248 | pub repository: Repository, |
249 | pub owner: User, |
250 | pub visibility: RepositoryVisibility, |
251 | pub description: , |
252 | pub last_commit: , |
253 | |
254 | |
255 | |
256 | |
257 | pub name: String, |
258 | pub color: String, |
259 | |
260 | |
261 | |
262 | |
263 | pub author: User, |
264 | pub id: u64, |
265 | pub title: String, |
266 | pub contents: String, |
267 | pub labels: , |
268 | |
269 |