Skip to content

Commit

Permalink
Fix install script (#509)
Browse files Browse the repository at this point in the history
- Use GitHub API to fetch latest release
- Use more secure cURL options
- Give up on signing commits
  • Loading branch information
casey authored Nov 19, 2022
1 parent 984543f commit 2a748fc
Show file tree
Hide file tree
Showing 25 changed files with 96 additions and 146 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ jobs:
key: cargo-${{ env.CACHE_KEY }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}

- name: Install Rust Toolchain Components
run: |
rustup component add clippy rustfmt
uses: actions-rs/toolchain@v1
with:
components: clippy, rustfmt
override: true
toolchain: 1.56.0

- name: Info
run: |
Expand All @@ -88,16 +91,8 @@ jobs:
brew install ripgrep
./bin/lint
- name: Install Nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{matrix.target}}
profile: minimal
components: rustfmt

- name: Check Formatting
run: cargo +nightly fmt --all -- --check
run: cargo fmt --all -- --check

- name: Check Generated
if: matrix.os == 'macos-latest'
Expand Down
12 changes: 9 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ For more about the project and its goals, check out
- [Benchmarks](#benchmarks)
- [Semantic Versioning](#semantic-versioning)
- [Unstable Features](#unstable-features)
- [Source Signatures](#source-signatures)
- [Acknowledgments](#acknowledgments)

## Installation
Expand Down Expand Up @@ -306,14 +305,6 @@ are unavailable unless the `--unstable` / `-u` flag is passed, for example
`imdl --unstable torrent create .`. Unstable features may be changed or removed
at any time.

## Source Signatures

All commits to the intermodal master branch signed with Casey Rodarmor's PGP
key with fingerprint `3259DAEDB29636B0E2025A70556186B153EC6FE0`, which can be
found
[on keybase](https://keybase.io/rodarmor/pgp_keys.asc?fingerprint=3259daedb29636b0e2025a70556186b153ec6fe0) and on
[his homepage](https://rodarmor.com/static/rodarmor.asc).

## Acknowledgments

The formatting of `imdl torrent show` is entirely copied from
Expand Down
2 changes: 1 addition & 1 deletion benches/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use imdl::bench::{Bench, HasherBench};
fn bench(c: &mut Criterion) {
let bench = HasherBench::init();

c.bench_function(&bench.name(), |b| b.iter(|| bench.iter()));
c.bench_function(&bench.name(), |b| b.iter(|| bench.iteration()));
}

criterion_group!(benches, bench);
Expand Down
8 changes: 0 additions & 8 deletions bin/gen/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,6 @@ are unavailable unless the `--unstable` / `-u` flag is passed, for example
`imdl --unstable torrent create .`. Unstable features may be changed or removed
at any time.

## Source Signatures

All commits to the intermodal master branch signed with Casey Rodarmor's PGP
key with fingerprint `3259DAEDB29636B0E2025A70556186B153EC6FE0`, which can be
found
[on keybase](https://keybase.io/rodarmor/pgp_keys.asc?fingerprint=3259daedb29636b0e2025a70556186b153ec6fe0) and on
[his homepage](https://rodarmor.com/static/rodarmor.asc).

## Acknowledgments

The formatting of `imdl torrent show` is entirely copied from
Expand Down
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

23 changes: 6 additions & 17 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
comment_width = 80
edition = "2018"
error_on_line_overflow = true
error_on_unformatted = true
format_code_in_doc_comments = true
format_macro_bodies = true
format_strings = true
imports_granularity = "Crate"
max_width = 100
newline_style = "Unix"
normalize_comments = true
reorder_impl_items = true
tab_spaces = 2
unstable_features = true
use_field_init_shorthand = true
use_try_shorthand = true
wrap_comments = true
edition = "2018"
max_width = 100
newline_style = "Unix"
tab_spaces = 2
use_field_init_shorthand = true
use_try_shorthand = true
4 changes: 2 additions & 2 deletions src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait Bench {

fn name(&self) -> String;

fn iter(&self);
fn iteration(&self);
}

pub struct HasherBench {
Expand Down Expand Up @@ -51,7 +51,7 @@ impl Bench for HasherBench {
Self { tempfile }
}

fn iter(&self) {
fn iteration(&self) {
let files = Files::file(
self.tempfile.as_ref().to_owned(),
Bytes::from(TEMPFILE_BYTES),
Expand Down
2 changes: 1 addition & 1 deletion src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Capture {
}

pub(crate) fn string(&self) -> String {
str::from_utf8(&self.cursor.borrow().get_ref())
str::from_utf8(self.cursor.borrow().get_ref())
.unwrap()
.to_owned()
}
Expand Down
8 changes: 5 additions & 3 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,11 @@ mod tests {
};
env.status().ok();
let err = env.err();
if !err.starts_with("error: Failed to parse announce URL:") {
panic!("Unexpected standard error output: {}", err);
}
assert!(
err.starts_with("error: Failed to parse announce URL:"),
"Unexpected standard error output: {}",
err
);

assert_eq!(env.out(), "");
}
Expand Down
2 changes: 1 addition & 1 deletion src/file_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl FilePath {

#[cfg(test)]
pub(crate) fn from_components(components: &[&str]) -> FilePath {
let components: Vec<String> = components.iter().cloned().map(ToOwned::to_owned).collect();
let components: Vec<String> = components.iter().copied().map(ToOwned::to_owned).collect();
assert!(!components.is_empty());
FilePath { components }
}
Expand Down
2 changes: 1 addition & 1 deletion src/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Hasher {

pub(crate) fn hash_files(mut self, files: &Files) -> Result<(Mode, PieceList), Error> {
let mode = if let Some(contents) = files.contents() {
let files = self.hash_contents(&files.root(), contents)?;
let files = self.hash_contents(files.root(), contents)?;

Mode::Multiple { files }
} else {
Expand Down
6 changes: 4 additions & 2 deletions src/host_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl FromStr for HostPort {
.invariant_unwrap("Capture group `port` always present")
.as_str();

let host = Host::parse(&host_text).context(host_port_parse_error::Host {
let host = Host::parse(host_text).context(host_port_parse_error::Host {
text: text.to_owned(),
})?;

Expand Down Expand Up @@ -109,7 +109,9 @@ mod tests {

fn case(host: Host, port: u16, text: &str, bencode: &str) {
let node = HostPort { host, port };
let parsed: HostPort = text.parse().expect(&format!("Failed to parse {}", text));
let parsed: HostPort = text
.parse()
.unwrap_or_else(|_| panic!("Failed to parse {}", text));
assert_eq!(parsed, node);
let ser = bendy::serde::to_bytes(&node).unwrap();
assert_eq!(
Expand Down
35 changes: 4 additions & 31 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,42 +1,15 @@
#![deny(clippy::all, clippy::pedantic, clippy::restriction)]
#![deny(clippy::all, clippy::pedantic)]
#![allow(
clippy::blanket_clippy_restriction_lints,
clippy::create_dir,
clippy::else_if_without_else,
clippy::enum_glob_use,
clippy::float_arithmetic,
clippy::float_cmp,
clippy::implicit_return,
clippy::indexing_slicing,
clippy::integer_arithmetic,
clippy::integer_division,
clippy::large_enum_variant,
clippy::map_unwrap_or,
clippy::missing_docs_in_private_items,
clippy::missing_inline_in_public_items,
clippy::module_name_repetitions,
clippy::needless_lifetimes,
clippy::needless_pass_by_value,
clippy::non_ascii_literal,
clippy::pattern_type_mismatch,
clippy::shadow_reuse,
clippy::struct_excessive_bools,
clippy::too_many_lines,
clippy::unseparated_literal_suffix,
clippy::wildcard_enum_match_arm,
clippy::wildcard_imports
)]
#![cfg_attr(
any(test),
allow(
clippy::blacklisted_name,
clippy::expect_fun_call,
clippy::expect_used,
clippy::panic,
clippy::panic_in_result_fn,
clippy::unwrap_in_result,
clippy::unwrap_used
)
clippy::wildcard_imports,
clippy::large_enum_variant,
clippy::module_name_repetitions
)]

#[cfg(test)]
Expand Down
8 changes: 4 additions & 4 deletions src/magnet_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl MagnetLink {

if let Some(name) = &self.name {
query.push_str("&dn=");
query.push_str(&name);
query.push_str(name);
}

for tracker in &self.trackers {
Expand Down Expand Up @@ -86,7 +86,7 @@ impl MagnetLink {
}

fn parse(text: &str) -> Result<Self, MagnetLinkParseError> {
let url = Url::parse(&text).context(magnet_link_parse_error::Url)?;
let url = Url::parse(text).context(magnet_link_parse_error::Url)?;

if url.scheme() != "magnet" {
return Err(MagnetLinkParseError::Scheme {
Expand Down Expand Up @@ -258,7 +258,7 @@ mod tests {
link_to.add_peer("foo.com:1337".parse().unwrap());
link_to.add_peer("bar.net:666".parse().unwrap());

let link_from = MagnetLink::from_str(&link_to.to_url().to_string()).unwrap();
let link_from = MagnetLink::from_str(link_to.to_url().as_ref()).unwrap();

assert_eq!(link_to, link_from);
}
Expand Down Expand Up @@ -314,7 +314,7 @@ mod tests {
#[test]
fn link_from_str_topic_missing() {
let link = "magnet:?";
let e = MagnetLink::from_str(&link).unwrap_err();
let e = MagnetLink::from_str(link).unwrap_err();

assert_matches!(e,
Error::MagnetLinkParse {
Expand Down
10 changes: 5 additions & 5 deletions src/metainfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Metainfo {
}

pub(crate) fn deserialize(source: &InputTarget, data: &[u8]) -> Result<Metainfo, Error> {
let metainfo = bendy::serde::de::from_bytes(&data).context(error::MetainfoDeserialize {
let metainfo = bendy::serde::de::from_bytes(data).context(error::MetainfoDeserialize {
input: source.clone(),
})?;
Ok(metainfo)
Expand Down Expand Up @@ -144,7 +144,7 @@ impl Metainfo {
piece_length: Bytes(16 * 1024),
source: Some("SOURCE".into()),
name: "NAME".into(),
pieces: PieceList::from_pieces(&["fae50", "fae50"]),
pieces: PieceList::from_pieces(["fae50", "fae50"]),
mode: Mode::Single {
length: Bytes(32 * 1024),
md5sum: Some(Md5Digest::from_hex("000102030405060708090a0b0c0d0e0f")),
Expand Down Expand Up @@ -192,7 +192,7 @@ impl Metainfo {
piece_length: Bytes(1024),
source: None,
name: "NAME".into(),
pieces: PieceList::from_pieces(&["fae50"]),
pieces: PieceList::from_pieces(["fae50"]),
mode: Mode::Single {
length: Bytes(5),
md5sum: None,
Expand Down Expand Up @@ -227,7 +227,7 @@ impl Metainfo {
piece_length: Bytes(1024),
source: None,
name: "NAME".into(),
pieces: PieceList::from_pieces(&["fae50"]),
pieces: PieceList::from_pieces(["fae50"]),
mode: Mode::Multiple {
files: vec![FileInfo {
length: Bytes(1024),
Expand Down Expand Up @@ -420,7 +420,7 @@ mod tests {
fn assert_trackers_eq(metainfo: &Metainfo, want: &[&str]) {
let want = want
.iter()
.cloned()
.copied()
.map(Url::parse)
.collect::<Result<Vec<Url>, url::ParseError>>()
.unwrap();
Expand Down
8 changes: 1 addition & 7 deletions src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ impl Status {
#[cfg(test)]
pub(crate) fn count_bad(&self) -> usize {
match self {
Self::Single { error, .. } => {
if error.is_some() {
1
} else {
0
}
}
Self::Single { error, .. } => error.is_some().into(),
Self::Multiple { files, .. } => files.iter().filter(|file| file.is_bad()).count(),
}
}
Expand Down
Loading

0 comments on commit 2a748fc

Please sign in to comment.