diff options
| author | Teddy Wing | 2021-05-30 17:14:25 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2021-05-30 17:14:25 +0200 | 
| commit | f8971cea4f8f916bbb528169f06c513c2a18802e (patch) | |
| tree | de07b47deee291182020dfe5e68fbc75fb9bcac3 /src/github.rs | |
| parent | 7fc7462bdb6565fa4e49a9f15099f8faed5385b5 (diff) | |
| download | reflectub-f8971cea4f8f916bbb528169f06c513c2a18802e.tar.bz2 | |
main::update(): Update repository description on fetch update
If the repository was updated, write the description into the
`description` file.
Add a `github::Repo.description()` method to get an empty string if the
description is `None`. This facilitates writing to the `description`
file.
Diffstat (limited to 'src/github.rs')
| -rw-r--r-- | src/github.rs | 9 | 
1 files changed, 9 insertions, 0 deletions
| diff --git a/src/github.rs b/src/github.rs index 0b20abd..b937f9b 100644 --- a/src/github.rs +++ b/src/github.rs @@ -31,6 +31,15 @@ pub struct Repo {      pub updated_at: String,  // TODO: Maybe parse to date?  } +impl Repo { +    /// Get the repository description or an empty string if `None`. +    pub fn description(&self) -> &str { +        self.description +            .as_deref() +            .unwrap_or("") +    } +} +  pub fn fetch_repos() -> Result<Vec<Repo>, Error> {      let mut headers = reqwest::header::HeaderMap::new(); | 
