jaemk / self_update

Self updates for rust executables
MIT License
798 stars 70 forks source link

skip `sha` (`sha1`, `sha256`, `sha512`) checksum files #130

Open brianheineman opened 5 months ago

brianheineman commented 5 months ago

Skip sha (sha1, sha256, sha512) checksum files when determining the release asset. Many projects (e.g. https://github.com/BurntSushi/ripgrep/releases, https://github.com/theseus-rs/rsql/releases, etc) include hash files with their releases, this change ignores the .sha* hash files when attempting to find the release archive.

jaemk commented 4 months ago

hey @brianheineman, thanks for adding this! Could you make this configurable? either adding a skip_extensions: Option<&[&str]> argument or ideally to maintain backwards compatibility adding a separate method asset_for_config(config: &AssetMatchConfig) that takes some new config struct with the options

brianheineman commented 4 months ago

Hello @jaemk, I made changes that should be more flexible and backwards compatible by allowing a "match function" to be specified.

fn update() -> Result<(), Box<::std::error::Error>> {
    let status = self_update::backends::github::Update::configure()
        .repo_owner("jaemk")
        .repo_name("self_update")
        .bin_name("github")
        .show_download_progress(true)
        .current_version(cargo_crate_version!())
        .asset_match_fn(|release, target, identifier| {
            // custom matching logic here
            ...
        })
        .build()?
        .update()?;
    println!("Update status: `{}`!", status.version());
    Ok(())
}

Please let me know if this achieves what you were looking for.