aiken new: Try to get the latest tag of stdlib
This commit is contained in:
1
crates/aiken-project/src/github/mod.rs
Normal file
1
crates/aiken-project/src/github/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod repo;
|
||||
22
crates/aiken-project/src/github/repo.rs
Normal file
22
crates/aiken-project/src/github/repo.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use reqwest::{blocking::Client, header::USER_AGENT, Error};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct LatestRelease {
|
||||
pub tag_name: String,
|
||||
}
|
||||
|
||||
impl LatestRelease {
|
||||
pub fn of<Repo: AsRef<str>>(repo: Repo) -> Result<Self, Error> {
|
||||
Ok({
|
||||
Client::new()
|
||||
.get(format!(
|
||||
"https://api.github.com/repos/{}/releases/latest",
|
||||
repo.as_ref()
|
||||
))
|
||||
.header(USER_AGENT, "aiken")
|
||||
.send()?
|
||||
.json::<Self>()?
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user