JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

test

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨4c7437a

Showing ⁨⁨5⁩ changed files⁩ with ⁨⁨48⁩ insertions⁩ and ⁨⁨12⁩ deletions⁩

giterated-models/src/error.rs

View file
@@ -15,7 +15,10 @@ pub enum RepositoryError {}
15 15 pub enum UserError {}
16 16
17 17 #[derive(Debug, thiserror::Error, Serialize, Deserialize)]
18 pub enum GetValueError {}
18 pub enum GetValueError {
19 #[error("invalid object")]
20 InvalidObject
21 }
19 22
20 23 #[derive(Serialize, Deserialize, Debug, thiserror::Error)]
21 24 pub enum OperationError<B> {

giterated-models/src/repository/mod.rs

View file
@@ -124,13 +124,13 @@ pub struct RepositoryView {
124 124 /// Owner of the Repository
125 125 pub owner: User,
126 126 /// Repository description
127 pub description: Option<String>,
127 pub description: Option<Description>,
128 128 /// Repository visibility
129 pub visibility: RepositoryVisibility,
129 pub visibility: Visibility,
130 130 /// Default branch of the repository
131 pub default_branch: String,
131 pub default_branch: DefaultBranch,
132 132 /// Last commit made to the repository
133 pub latest_commit: Option<Commit>,
133 pub latest_commit: Option<LatestCommit>,
134 134 /// Revision of the displayed tree
135 135 pub tree_rev: Option<String>,
136 136 /// Repository tree
@@ -178,7 +178,7 @@ pub struct RepositoryTreeEntryWithCommit {
178 178 }
179 179
180 180 /// Info about a git commit
181 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
181 #[derive(PartialEq, Hash, Eq, Debug, Clone, Serialize, Deserialize)]
182 182 pub struct Commit {
183 183 /// Unique commit ID
184 184 pub oid: String,
@@ -219,7 +219,7 @@ impl From<git2::Commit<'_>> for Commit {
219 219 }
220 220
221 221 /// Git commit signature
222 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
222 #[derive(PartialEq, Hash, Eq, Debug, Clone, Serialize, Deserialize)]
223 223 pub struct CommitSignature {
224 224 pub name: Option<String>,
225 225 pub email: Option<String>,

giterated-models/src/repository/operations.rs

View file
@@ -7,7 +7,7 @@ use crate::{
7 7 operation::GiteratedOperation,
8 8 };
9 9
10 use super::{IssueLabel, Repository, RepositoryIssue, RepositoryTreeEntry, RepositoryView};
10 use super::{IssueLabel, Repository, RepositoryIssue, RepositoryTreeEntry, RepositoryView, Commit};
11 11
12 12 /// A request to get a repository's information.
13 13 ///
@@ -83,7 +83,8 @@ impl GiteratedOperation<Repository> for RepositoryIssuesRequest {
83 83 /// - Potential User permissions checks
84 84 #[derive(Clone, Debug, Serialize, Deserialize)]
85 85 pub struct RepositoryFileInspectRequest {
86 pub path: RepositoryTreeEntry,
86 pub rev: Option<String>,
87 pub path: String,
87 88 }
88 89
89 90 impl GiteratedOperation<Repository> for RepositoryFileInspectRequest {
@@ -121,10 +122,12 @@ impl<B: ObjectBackend + std::fmt::Debug> Object<'_, Repository, B> {
121 122
122 123 pub async fn inspect_files(
123 124 &mut self,
124 entry: &RepositoryTreeEntry,
125 path: &String,
126 rev: Option<&str>
125 127 ) -> Result<Vec<RepositoryTreeEntry>, OperationError<RepositoryError>> {
126 128 self.request::<RepositoryFileInspectRequest>(RepositoryFileInspectRequest {
127 path: entry.clone(),
129 rev: rev.map(|r| r.to_string()),
130 path: path.clone(),
128 131 })
129 132 .await
130 133 }

giterated-models/src/repository/settings.rs

View file
@@ -2,6 +2,8 @@ use serde::{Deserialize, Serialize};
2 2
3 3 use crate::settings::Setting;
4 4
5 use super::DefaultBranch;
6
5 7 #[derive(Debug, Serialize, Deserialize)]
6 8 pub struct RepositoryDescription(pub String);
7 9
@@ -19,3 +21,9 @@ impl Setting for RepositoryVisibilitySetting {
19 21 "Repository Visibility"
20 22 }
21 23 }
24
25 impl Setting for DefaultBranch {
26 fn name() -> &'static str {
27 "Default Branch"
28 }
29 }
29 \ No newline at end of file

giterated-models/src/repository/values.rs

View file
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
4 4
5 5 use crate::{settings::Setting, value::GiteratedObjectValue};
6 6
7 use super::{Repository, RepositoryVisibility};
7 use super::{Repository, RepositoryVisibility, Commit};
8 8
9 9 // pub struct RepositorySetting<V: GiteratedObjectValue>(pub V);
10 10
@@ -51,3 +51,25 @@ impl GiteratedObjectValue for Visibility {
51 51 "visibility"
52 52 }
53 53 }
54
55 #[derive(Debug, Hash, Clone, PartialEq, Eq, Serialize, Deserialize)]
56 pub struct DefaultBranch(pub String);
57
58 impl GiteratedObjectValue for DefaultBranch {
59 type Object = Repository;
60
61 fn value_name() -> &'static str {
62 "default_branch"
63 }
64 }
65
66 #[derive(Debug, Hash, Clone, PartialEq, Eq, Serialize, Deserialize)]
67 pub struct LatestCommit(pub Commit);
68
69 impl GiteratedObjectValue for LatestCommit {
70 type Object = Repository;
71
72 fn value_name() -> &'static str {
73 "latest_commit"
74 }
75 }