Skip to content

Commit

Permalink
fix(GitHubSource): borrowing
Browse files Browse the repository at this point in the history
Co-authored-by: Filip Tibell <filip.tibell@gmail.com>
  • Loading branch information
sasial-dev and filiptibell committed Sep 5, 2022
1 parent 3437ec6 commit c106675
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/tool_source/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub struct GitHubSource {
}

impl GitHubSource {
pub fn new(auth: Option<AuthManifest>) -> Self {
pub fn new(auth: Option<&AuthManifest>) -> Self {
Self {
client: Client::new(),
token: auth.map(|t| t.github).flatten()
token: auth.and_then(|t| t.github.clone())
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/tool_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl ToolStorage {
log::info!("Installing tool: {}", spec);

log::debug!("Fetching GitHub releases...");
let github = self.github.get_or_init(|| GitHubSource::new(self.auth));
let github = self.github.get_or_init(|| GitHubSource::new(self.auth.as_ref()));
let mut releases = github.get_all_releases(spec.name())?;
releases.sort_by(|a, b| a.version.cmp(&b.version).reverse());

Expand Down Expand Up @@ -237,7 +237,7 @@ impl ToolStorage {
log::info!("Installing tool: {id}");

log::debug!("Fetching GitHub release...");
let github = self.github.get_or_init(|| GitHubSource::new(self.auth));
let github = self.github.get_or_init(|| GitHubSource::new(self.auth.as_ref()));
let release = github.get_release(id)?;

let mut compatible_assets = self.get_compatible_assets(&release);
Expand Down

0 comments on commit c106675

Please sign in to comment.