Fixes
parent: tbd commit: b87f0a3
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: RepositoryVisibility, |
130 | /// Default branch of the repository |
131 | pub default_branch: String, |
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 | Tree, |
143 | Blob, |
144 | |
145 | |
146 | /// Stored info for our tree entries |
147 | |
148 | |
149 | /// Name of the tree/blob |
150 | pub name: String, |
151 | /// Type of the tree entry |
152 | pub object_type: RepositoryObjectType, |
153 | /// Git supplies us with the mode at all times, and people like it displayed. |
154 | pub mode: i32, |
155 | /// File size |
156 | pub size: , |
157 | /// Last commit made to the tree/blob |
158 | pub last_commit: , |
159 | |
160 | |
161 | |
162 | // I love you Emilia <3 |
163 | |
164 | Self |
165 | name: name.to_string, |
166 | object_type, |
167 | mode, |
168 | size: None, |
169 | last_commit: None, |
170 | |
171 | |
172 | |
173 | |
174 | |
175 | |
176 | pub tree_entry: RepositoryTreeEntry, |
177 | pub commit: Commit, |
178 | |
179 | |
180 | /// Info about a git commit |
181 | |
182 | |
183 | /// Unique commit ID |
184 | pub oid: String, |
185 | /// Shortened abbreviated OID |
186 | /// This starts at the git config's "core.abbrev" length (default 7 characters) and |
187 | /// iteratively extends to a longer string if that length is ambiguous. The |
188 | /// result will be unambiguous (at least until new objects are added to the repository). |
189 | pub short_oid: String, |
190 | /// Full commit message |
191 | pub message: , |
192 | /// Who created the commit |
193 | pub author: CommitSignature, |
194 | /// Who committed the commit |
195 | pub committer: CommitSignature, |
196 | /// Time when the commit happened |
197 | pub time: NaiveDateTime, |
198 | |
199 | |
200 | /// Gets all info from [`git2::Commit`] for easy use |
201 | |
202 | |
203 | Self |
204 | oid: commit.id .to_string, |
205 | // This shouldn't ever fail, as we already know the object has an oid. |
206 | short_oid: commit |
207 | .as_object |
208 | .short_id |
209 | .unwrap |
210 | .as_str |
211 | .unwrap |
212 | .to_string, |
213 | message: commit.message .map, |
214 | author: commit.author .into, |
215 | committer: commit.committer .into, |
216 | time: from_timestamp_opt .unwrap, |
217 | |
218 | |
219 | |
220 | |
221 | /// Git commit signature |
222 | |
223 | |
224 | pub name: , |
225 | pub email: , |
226 | pub time: NaiveDateTime, |
227 | |
228 | |
229 | /// Converts the signature from git2 into something usable without explicit lifetimes. |
230 | |
231 | |
232 | Self |
233 | name: signature.name .map, |
234 | email: signature.email .map, |
235 | time: from_timestamp_opt .unwrap, |
236 | |
237 | |
238 | |
239 | |
240 | |
241 | |
242 | pub repository: Repository, |
243 | pub owner: User, |
244 | pub visibility: RepositoryVisibility, |
245 | pub description: , |
246 | pub last_commit: , |
247 | |
248 | |
249 | |
250 | |
251 | pub name: String, |
252 | pub color: String, |
253 | |
254 | |
255 | |
256 | |
257 | pub author: User, |
258 | pub id: u64, |
259 | pub title: String, |
260 | pub contents: String, |
261 | pub labels: , |
262 | |
263 |