-
-
Notifications
You must be signed in to change notification settings - Fork 367
Expand file tree
/
Copy pathgit_rpc.rs
More file actions
145 lines (128 loc) · 5.13 KB
/
git_rpc.rs
File metadata and controls
145 lines (128 loc) · 5.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use serde_json::Value;
pub(crate) const METHOD_GET_GIT_STATUS: &str = "get_git_status";
pub(crate) const METHOD_INIT_GIT_REPO: &str = "init_git_repo";
pub(crate) const METHOD_CREATE_GITHUB_REPO: &str = "create_github_repo";
pub(crate) const METHOD_STAGE_GIT_FILE: &str = "stage_git_file";
pub(crate) const METHOD_STAGE_GIT_ALL: &str = "stage_git_all";
pub(crate) const METHOD_APPLY_GIT_DISPLAY_HUNK: &str = "apply_git_display_hunk";
pub(crate) const METHOD_UNSTAGE_GIT_FILE: &str = "unstage_git_file";
pub(crate) const METHOD_REVERT_GIT_FILE: &str = "revert_git_file";
pub(crate) const METHOD_REVERT_GIT_ALL: &str = "revert_git_all";
pub(crate) const METHOD_COMMIT_GIT: &str = "commit_git";
pub(crate) const METHOD_PUSH_GIT: &str = "push_git";
pub(crate) const METHOD_PULL_GIT: &str = "pull_git";
pub(crate) const METHOD_FETCH_GIT: &str = "fetch_git";
pub(crate) const METHOD_SYNC_GIT: &str = "sync_git";
pub(crate) const METHOD_LIST_GIT_ROOTS: &str = "list_git_roots";
pub(crate) const METHOD_GET_GIT_DIFFS: &str = "get_git_diffs";
pub(crate) const METHOD_GET_GIT_LOG: &str = "get_git_log";
pub(crate) const METHOD_GET_GIT_COMMIT_DIFF: &str = "get_git_commit_diff";
pub(crate) const METHOD_GET_GIT_REMOTE: &str = "get_git_remote";
pub(crate) const METHOD_GET_GITHUB_ISSUES: &str = "get_github_issues";
pub(crate) const METHOD_GET_GITHUB_PULL_REQUESTS: &str = "get_github_pull_requests";
pub(crate) const METHOD_GET_GITHUB_PULL_REQUEST_DIFF: &str = "get_github_pull_request_diff";
pub(crate) const METHOD_GET_GITHUB_PULL_REQUEST_COMMENTS: &str = "get_github_pull_request_comments";
pub(crate) const METHOD_CHECKOUT_GITHUB_PULL_REQUEST: &str = "checkout_github_pull_request";
pub(crate) const METHOD_LIST_GIT_BRANCHES: &str = "list_git_branches";
pub(crate) const METHOD_CHECKOUT_GIT_BRANCH: &str = "checkout_git_branch";
pub(crate) const METHOD_CREATE_GIT_BRANCH: &str = "create_git_branch";
#[allow(dead_code)]
pub(crate) const METHOD_GENERATE_COMMIT_MESSAGE: &str = "generate_commit_message";
#[allow(dead_code)]
pub(crate) fn to_params<T: Serialize>(request: &T) -> Result<Value, String> {
serde_json::to_value(request).map_err(|err| err.to_string())
}
#[allow(dead_code)]
pub(crate) fn from_params<T: DeserializeOwned>(params: &Value) -> Result<T, String> {
serde_json::from_value(params.clone()).map_err(|err| err.to_string())
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct WorkspaceIdRequest {
pub(crate) workspace_id: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct InitGitRepoRequest {
pub(crate) workspace_id: String,
pub(crate) branch: String,
pub(crate) force: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct InitGitRepoRequiredRequest {
pub(crate) workspace_id: String,
pub(crate) branch: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct CreateGitHubRepoRequest {
pub(crate) workspace_id: String,
pub(crate) repo: String,
pub(crate) visibility: String,
pub(crate) branch: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct CreateGitHubRepoRequiredRequest {
pub(crate) workspace_id: String,
pub(crate) repo: String,
pub(crate) visibility: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct WorkspacePathRequest {
pub(crate) workspace_id: String,
pub(crate) path: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct GitDisplayHunkActionRequest {
pub(crate) workspace_id: String,
pub(crate) path: String,
pub(crate) display_hunk_id: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ListGitRootsRequest {
pub(crate) workspace_id: String,
pub(crate) depth: Option<u32>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct GetGitLogRequest {
pub(crate) workspace_id: String,
pub(crate) limit: Option<u32>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct WorkspaceShaRequest {
pub(crate) workspace_id: String,
pub(crate) sha: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct WorkspaceMessageRequest {
pub(crate) workspace_id: String,
pub(crate) message: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct GitHubPullRequestRequest {
pub(crate) workspace_id: String,
pub(crate) pr_number: u64,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct WorkspaceNameRequest {
pub(crate) workspace_id: String,
pub(crate) name: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct GenerateCommitMessageRequest {
pub(crate) workspace_id: String,
pub(crate) commit_message_model_id: Option<String>,
}