8 个版本
0.1.8 | 2022年6月14日 |
---|---|
0.1.6 | 2022年3月17日 |
0.1.3 | 2021年12月25日 |
#1119 在 异步
每月 39 次下载
23KB
617 行
Gritea
Gritea
是一个异步 Gittea API SDK。
使用示例
use anyhow::Context;
use gritea::{client::Gritea, pagination::Pagination, repo::CreateHookOption, Result};
use maplit::hashmap;
use std::env;
#[tokio::main]
async fn main() -> Result<()> {
let cli =
Gritea::builder("git.dreamszl.cc")
.token(env::var("ACCESS_TOKEN").with_context(|| {
format!("get environment variable ACCESS_TOKEN failed")
})?)
.build()?;
let user = cli.current_user().await?;
println!("{:#?}", user);
let repo = cli.get_repo("op", "jarvis").await?;
println!("{:#?}", repo);
let _repos = cli.list_repos(&Pagination::default()).await?;
// println!("{:#?}", _repos);
let hook = cli
.create_hook(
"op",
"jarvis",
&CreateHookOption {
type_: "gitea".to_string(),
config: hashmap! {
"url".to_string() => "http://foo.bar/hook".to_string(),
"content_type".to_string() => "json".to_string(),
"secret".to_string() => "foo".to_string(),
},
events: vec!["push".to_string()],
branch_filter: "*".to_string(),
active: true,
},
)
.await?;
println!("{:#?}", hook);
Ok(())
}
许可证
此项目遵循 MIT 许可证。
依赖项
~7–20MB
~300K SLoC