diff options
| author | Teddy Wing | 2021-06-06 20:09:16 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2021-06-06 20:09:16 +0200 | 
| commit | 177ba20c66b81794d539a5fa0500cf0a9e0ef259 (patch) | |
| tree | c068da51272c46edc5d771fe1630ef33dfec560c /src | |
| parent | 352a486fee986118a2865316d2d1ab8e6de69b48 (diff) | |
| download | reflectub-177ba20c66b81794d539a5fa0500cf0a9e0ef259.tar.bz2 | |
main::run(): Get repositories from GitHub API call
Remove the hard-coded test repositories I was using and replace them
with real ones retrieved from the GitHub API.
Enable I/O and timers on the Tokio runtime in order to enable the async
GitHub API request.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 36 | 
1 files changed, 6 insertions, 30 deletions
| diff --git a/src/main.rs b/src/main.rs index b0474bf..1379e09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,37 +91,13 @@ fn run() -> anyhow::Result<()> {      let base_cgitrc = opt_matches.opt_str("cgitrc")          .map(|s| PathBuf::from(s)); -    let rt = tokio::runtime::Builder::new_multi_thread().build()?; +    let rt = tokio::runtime::Builder::new_multi_thread() +        .enable_io() +        .enable_time() +        .build()?;      let _rt_guard = rt.enter(); -    // let repos = github::fetch_repos(username).await? - -    let test_repos = vec![ -        github::Repo { -            id: 345367151, -            name: "DDHotKey".to_owned(), -            description: Some( -                "Simple Cocoa global hotkeys".to_owned(), -            ), -            fork: true, -            git_url: "git://github.com/teddywing/DDHotKey.git".to_owned(), -            default_branch: "master".to_owned(), -            size: 81, -            updated_at: "2021-03-07T14:27:06Z".to_owned(), -        }, -        github::Repo { -            id: 312106271, -            name: "apple-developer-objc".to_owned(), -            description: Some( -                "A user script that forces Apple Developer documentation to use Objective-C".to_owned(), -            ), -            fork: false, -            git_url: "git://github.com/teddywing/apple-developer-objc.git".to_owned(), -            default_branch: "master".to_owned(), -            size: 13, -            updated_at: "2020-11-11T22:49:53Z".to_owned(), -        }, -    ]; +    let repos = executor::block_on(github::fetch_repos(username))?;      let db = Arc::new(          tokio::sync::Mutex::new( @@ -135,7 +111,7 @@ fn run() -> anyhow::Result<()> {      let mut joins = Vec::new(); -    for repo in test_repos { +    for repo in repos {          let db = db.clone();          let mirror_root = mirror_root.clone();          let base_cgitrc = base_cgitrc.clone(); | 
