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