Add docs
parent: tbd commit: 51aad53
1 | use FromStr; |
2 | |
3 | use ; |
4 | |
5 | use ; |
6 | |
7 | /// A repository, defined by the instance it exists on along with |
8 | /// its owner and name. |
9 | /// |
10 | /// # Textual Format |
11 | /// A repository's textual reference is defined as: |
12 | /// |
13 | /// `{owner: User}/{name: String}@{instance: Instance}` |
14 | /// |
15 | /// # Examples |
16 | /// For the repository named `foo` owned by `barson:giterated.dev` on the instance |
17 | /// `giterated.dev`, the following [`Repository`] initialization would |
18 | /// be valid: |
19 | /// |
20 | /// ``` |
21 | /// let repository = Repository { |
22 | /// owner: User::from_str("barson:giterated.dev").unwrap(), |
23 | /// name: String::from("foo"), |
24 | /// instance: Instance::from_str("giterated.dev").unwrap() |
25 | /// }; |
26 | /// |
27 | /// // This is correct |
28 | /// assert_eq!(Repository::from_str("barson:giterated.dev/[email protected]").unwrap(), repository); |
29 | /// ``` |
30 | |
31 | |
32 | pub owner: User, |
33 | pub name: String, |
34 | /// Instance the repository is on |
35 | pub instance: Instance, |
36 | |
37 | |
38 | |
39 | |
40 | format! |
41 | |
42 | |
43 | |
44 | |
45 | type Err = ; |
46 | |
47 | |
48 | let mut by_ampersand = s.split; |
49 | let mut path_split = by_ampersand.next .unwrap .split; |
50 | |
51 | let instance = from_str .unwrap; |
52 | let owner = from_str .unwrap; |
53 | let name = path_split.next .unwrap .to_string; |
54 | |
55 | Ok |
56 | instance, |
57 | owner, |
58 | name, |
59 | |
60 | |
61 | |
62 | |
63 | /// Visibility of the repository to the general eye |
64 | |
65 | |
66 | |
67 | Public, |
68 | Unlisted, |
69 | Private, |
70 | |
71 | |
72 | |
73 | |
74 | /// Name of the repository |
75 | /// |
76 | /// This is different than the [`Repository`] name, |
77 | /// which may be a path. |
78 | pub name: String, |
79 | /// Owner of the Repository |
80 | pub owner: User, |
81 | /// Repository description |
82 | pub description: , |
83 | /// Repository visibility |
84 | pub visibility: RepositoryVisibility, |
85 | /// Default branch of the repository |
86 | pub default_branch: String, |
87 | /// Last commit made to the repository |
88 | pub latest_commit: , |
89 | /// Revision of the displayed tree |
90 | pub tree_rev: , |
91 | /// Repository tree |
92 | pub tree: , |
93 | |
94 | |
95 | |
96 | |
97 | Tree, |
98 | Blob, |
99 | |
100 | |
101 | /// Stored info for our tree entries |
102 | |
103 | |
104 | /// Name of the tree/blob |
105 | pub name: String, |
106 | /// Type of the tree entry |
107 | pub object_type: RepositoryObjectType, |
108 | /// Git supplies us with the mode at all times, and people like it displayed. |
109 | pub mode: i32, |
110 | /// File size |
111 | pub size: , |
112 | /// Last commit made to the tree/blob |
113 | pub last_commit: , |
114 | |
115 | |
116 | |
117 | // I love you Emilia <3 |
118 | |
119 | Self |
120 | name: name.to_string, |
121 | object_type, |
122 | mode, |
123 | size: None, |
124 | last_commit: None, |
125 | |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | pub tree_entry: RepositoryTreeEntry, |
132 | pub commit: Commit, |
133 | |
134 | |
135 | /// Info about a git commit |
136 | |
137 | |
138 | /// Unique commit ID |
139 | pub oid: String, |
140 | /// Full commit message |
141 | pub message: , |
142 | /// Who created the commit |
143 | pub author: CommitSignature, |
144 | /// Who committed the commit |
145 | pub committer: CommitSignature, |
146 | /// Time when the commit happened |
147 | pub time: NaiveDateTime, |
148 | |
149 | |
150 | /// Gets all info from [`git2::Commit`] for easy use |
151 | |
152 | |
153 | Self |
154 | oid: commit.id .to_string, |
155 | message: commit.message .map, |
156 | author: commit.author .into, |
157 | committer: commit.committer .into, |
158 | time: from_timestamp_opt .unwrap, |
159 | |
160 | |
161 | |
162 | |
163 | /// Git commit signature |
164 | |
165 | |
166 | pub name: , |
167 | pub email: , |
168 | pub time: NaiveDateTime, |
169 | |
170 | |
171 | /// Converts the signature from git2 into something usable without explicit lifetimes. |
172 | |
173 | |
174 | Self |
175 | name: signature.name .map, |
176 | email: signature.email .map, |
177 | time: from_timestamp_opt .unwrap, |
178 | |
179 | |
180 | |
181 |