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

ambee/giterated

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

Initial git handling

Type: Feature

emilia - ⁨2⁩ years ago

parent: tbd commit: ⁨523decf

⁨src/messages/repository.rs⁩ - ⁨3058⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::model::repository::RepositoryVisibility;
4 use crate::model::{
5 repository::{Commit, Repository, RepositoryTreeEntry, RepositoryView},
6 user::User,
7 };
8
9 #[derive(Clone, Serialize, Deserialize)]
10 pub struct RepositoryMessage {
11 pub target: Repository,
12 pub command: RepositoryMessageKind,
13 }
14
15 #[derive(Clone, Serialize, Deserialize)]
16 pub enum RepositoryMessageKind {
17 Request(RepositoryRequest),
18 Response(RepositoryResponse),
19 }
20
21 #[derive(Clone, Serialize, Deserialize)]
22 pub enum RepositoryRequest {
23 CreateRepository(CreateRepositoryRequest),
24 RepositoryFileInspect(RepositoryFileInspectRequest),
25 RepositoryInfo(RepositoryInfoRequest),
26 IssuesCount(RepositoryIssuesCountRequest),
27 IssueLabels(RepositoryIssueLabelsRequest),
28 Issues(RepositoryIssuesRequest),
29 }
30
31 #[derive(Clone, Serialize, Deserialize)]
32 pub enum RepositoryResponse {
33 CreateRepository(CreateRepositoryResponse),
34 RepositoryFileInspection(RepositoryFileInspectionResponse),
35 RepositoryInfo(RepositoryView),
36 IssuesCount(RepositoryIssuesCountResponse),
37 IssueLabels(RepositoryIssueLabelsResponse),
38 Issues(RepositoryIssuesResponse),
39 }
40
41 #[derive(Clone, Serialize, Deserialize)]
42 pub struct CreateRepositoryRequest {
43 pub name: String,
44 pub description: Option<String>,
45 pub visibility: RepositoryVisibility,
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 RepositoryFileInspectRequest {
58 pub path: RepositoryTreeEntry,
59 }
60
61 #[derive(Clone, Serialize, Deserialize)]
62 pub enum RepositoryFileInspectionResponse {
63 File {
64 commit_metadata: Commit,
65 },
66 Folder {
67 commit_metadata: Commit,
68 members: Vec<RepositoryTreeEntry>,
69 },
70 Invalid {
71 path: RepositoryTreeEntry,
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 pub name: String,
117 pub owner: User,
118 pub rev: Option<String>,
119 pub path: Option<String>,
120 pub extra_metadata: bool,
121 }
122