Skip to content

Commit

Permalink
feat: read branches
Browse files Browse the repository at this point in the history
  • Loading branch information
gengteng committed Jun 18, 2024
1 parent 60c4b7b commit 77c6f18
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/rust-assistant/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-assistant"
version = "0.4.0"
version = "0.5.0"
description = "Rust Assistant Library."
authors = ["GengTeng <me@gteng.org>"]
license = "GPL-3.0"
Expand Down
76 changes: 38 additions & 38 deletions crates/rust-assistant/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,41 +331,41 @@ pub struct Author {
/// The author's name.
pub name: String,
}

#[cfg(test)]
mod tests {
use super::*;

#[tokio::test]
async fn test_get_file() -> anyhow::Result<()> {
let token = dotenv::var("GITHUB_ACCESS_TOKEN")?;
let proxy = if tokio::net::TcpStream::connect("127.0.0.1:7890")
.await
.is_ok()
{
Some(Proxy::all("http://127.0.0.1:7890")?)
} else {
None
};
let repo = Repository::from(("gengteng", "rust-assistant"));
// https://github.com/rust-lang/crates.io-index
let client = GithubClient::new(token.as_str(), proxy)?;
let content = client.get_file(&repo, "Cargo.toml", "fff").await?;
println!("content: {content:?}");

let dir = client.read_dir(&repo, "crates", None).await?;
println!("dir crates: {dir:#?}");

let issues = client.search_for_issues(&repo, "test").await?;
println!("issues: {issues:#?}");

for issue in issues {
let timeline = client.get_issue_timeline(&repo, issue.number).await?;
println!("timeline: {timeline:#?}");
}

let branches = client.get_repo_branches(&repo).await?;
println!("branches: {branches:#?}");
Ok(())
}
}
//
// #[cfg(test)]
// mod tests {
// use super::*;
//
// #[tokio::test]
// async fn test_get_file() -> anyhow::Result<()> {
// let token = dotenv::var("GITHUB_ACCESS_TOKEN")?;
// let proxy = if tokio::net::TcpStream::connect("127.0.0.1:7890")
// .await
// .is_ok()
// {
// Some(Proxy::all("http://127.0.0.1:7890")?)
// } else {
// None
// };
// let repo = Repository::from(("gengteng", "rust-assistant"));
// // https://github.com/rust-lang/crates.io-index
// let client = GithubClient::new(token.as_str(), proxy)?;
// let content = client.get_file(&repo, "Cargo.toml", "fff").await?;
// println!("content: {content:?}");
//
// let dir = client.read_dir(&repo, "crates", None).await?;
// println!("dir crates: {dir:#?}");
//
// let issues = client.search_for_issues(&repo, "test").await?;
// println!("issues: {issues:#?}");
//
// for issue in issues {
// let timeline = client.get_issue_timeline(&repo, issue.number).await?;
// println!("timeline: {timeline:#?}");
// }
//
// let branches = client.get_repo_branches(&repo).await?;
// println!("branches: {branches:#?}");
// Ok(())
// }
// }

0 comments on commit 77c6f18

Please sign in to comment.