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

ambee/giterated

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

Add backend trait and git backend stub

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨b9203a9

⁨src/command/repository.rs⁩ - ⁨2875⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::model::{
4 repository::{CommitMetadata, Repository, RepositoryFile, RepositoryView},
5 user::User,
6 };
7
8 use super::issues::IssuesCountResponse;
9
10 #[derive(Clone, Serialize, Deserialize)]
11 pub struct RepositoryMessage {
12 pub target: Repository,
13 pub command: RepositoryMessageKind,
14 }
15
16 #[derive(Clone, Serialize, Deserialize)]
17 pub enum RepositoryMessageKind {
18 Request(RepositoryRequest),
19 Response(RepositoryResponse),
20 }
21
22 #[derive(Clone, Serialize, Deserialize)]
23 pub enum RepositoryRequest {
24 CreateRepository(CreateRepositoryCommand),
25 RepositoryFileInspection(RepositoryFileInspectionCommand),
26 RepositoryInfo(RepositoryInfoRequest),
27 IssuesCount(RepositoryIssuesCountRequest),
28 IssueLabels(RepositoryIssueLabelsRequest),
29 Issues(RepositoryIssuesRequest),
30 }
31
32 #[derive(Clone, Serialize, Deserialize)]
33 pub enum RepositoryResponse {
34 CreateRepository(CreateRepositoryResponse),
35 RepositoryFileInspection(RepositoryFileInspectionResponse),
36 RepositoryInfo(RepositoryView),
37 IssuesCount(RepositoryIssuesCountResponse),
38 IssueLabels(RepositoryIssueLabelsResponse),
39 Issues(RepositoryIssuesResponse),
40 }
41
42 #[derive(Clone, Serialize, Deserialize)]
43 pub struct CreateRepositoryCommand {
44 pub name: String,
45 pub description: String,
46 pub default_branch: String,
47 pub owner: User,
48 }
49
50 #[derive(Clone, Serialize, Deserialize)]
51 pub enum CreateRepositoryResponse {
52 Created,
53 Failed,
54 }
55
56 #[derive(Clone, Serialize, Deserialize)]
57 pub struct RepositoryFileInspectionCommand {
58 pub path: RepositoryFile,
59 }
60
61 #[derive(Clone, Serialize, Deserialize)]
62 pub enum RepositoryFileInspectionResponse {
63 File {
64 commit_metadata: CommitMetadata,
65 },
66 Folder {
67 commit_metadata: CommitMetadata,
68 members: Vec<RepositoryFile>,
69 },
70 Invalid {
71 path: RepositoryFile,
72 },
73 }
74
75 #[derive(Clone, Serialize, Deserialize)]
76 pub struct RepositoryIssuesCountRequest;
77
78 #[derive(Clone, Serialize, Deserialize)]
79 pub struct RepositoryIssuesCountResponse {
80 pub count: u64,
81 }
82
83 #[derive(Clone, Serialize, Deserialize)]
84 pub struct RepositoryIssueLabelsRequest;
85
86 #[derive(Clone, Serialize, Deserialize)]
87 pub struct RepositoryIssueLabelsResponse {
88 pub labels: Vec<IssueLabel>,
89 }
90
91 #[derive(Clone, Serialize, Deserialize)]
92 pub struct IssueLabel {
93 pub name: String,
94 pub color: String,
95 }
96
97 #[derive(Clone, Serialize, Deserialize)]
98 pub struct RepositoryIssuesRequest;
99
100 #[derive(Clone, Serialize, Deserialize)]
101 pub struct RepositoryIssuesResponse {
102 pub issues: Vec<RepositoryIssue>,
103 }
104
105 #[derive(Clone, Serialize, Deserialize)]
106 pub struct RepositoryIssue {
107 pub author: User,
108 pub id: u64,
109 pub title: String,
110 pub contents: String,
111 pub labels: Vec<IssueLabel>,
112 }
113
114 #[derive(Clone, Serialize, Deserialize)]
115 pub struct RepositoryInfoRequest;
116