1use extism::{convert::Json, *};
2use fluentci_common::git::{
3 branch as common_branch, commit as common_commit, git as common_git, tree as common_tree,
4};
5use fluentci_types::git::Git;
6
7use crate::state::State;
8
9host_fn!(pub git(user_data: State; url: String) -> Json<Git> {
10 let state = user_data.get()?;
11 let state = state.lock().unwrap();
12 let graph = state.graph.clone();
13 let git = common_git(graph, url, true)?;
14 Ok(Json(Git::from(git)))
15});
16
17host_fn!(pub branch(user_data: State; name: String) {
18 let state = user_data.get()?;
19 let state = state.lock().unwrap();
20 let graph = state.graph.clone();
21 common_branch(graph, name)
22});
23
24host_fn!(pub commit(user_data: State;) -> String {
25 let state = user_data.get()?;
26 let state = state.lock().unwrap();
27 let graph = state.graph.clone();
28 common_commit(graph)
29});
30
31host_fn!(pub tree(user_data: State;) -> Json<Directory> {
32 let state = user_data.get()?;
33 let state = state.lock().unwrap();
34 let graph = state.graph.clone();
35 let directory = common_tree(graph)?;
36 Ok(Json(directory))
37});