From e5eb3e479b5a37bc50ffe60694482c322584ef24 Mon Sep 17 00:00:00 2001 From: Pi-Cla Date: Sun, 11 Aug 2024 01:06:12 -0600 Subject: Update Cargo.lock to openssl 0.10.66 https://rustsec.org/advisories/RUSTSEC-2024-0357 --- Cargo.lock | 169 ++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 105 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dcfad8d..08759eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,9 +28,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -43,33 +43,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -193,11 +193,17 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "caseless" @@ -211,9 +217,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292" dependencies = [ "jobserver", "libc", @@ -227,9 +233,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.11" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" +checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" dependencies = [ "clap_builder", "clap_derive", @@ -237,9 +243,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.11" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" dependencies = [ "anstream", "anstyle", @@ -250,9 +256,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck", "proc-macro2", @@ -262,15 +268,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "comrak" @@ -305,9 +311,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" @@ -543,9 +549,9 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", "miniz_oxide", @@ -936,9 +942,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ "bytes", "futures-util", @@ -973,9 +979,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown", @@ -1008,9 +1014,9 @@ dependencies = [ [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" @@ -1020,9 +1026,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] @@ -1209,9 +1215,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.1" +version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" dependencies = [ "memchr", ] @@ -1257,9 +1263,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.65" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2823eb4c6453ed64055057ea8bd416eda38c71018723869dd043a3b1186115e" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -1379,9 +1385,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" @@ -1462,9 +1471,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -1619,18 +1628,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" dependencies = [ "proc-macro2", "quote", @@ -1639,11 +1648,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1702,9 +1712,9 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", "mio 0.8.11", @@ -1769,9 +1779,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.71" +version = "2.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" +checksum = "837a7e8026c6ce912ff01cefbe8cafc2f8010ac49682e2a3d9decc3bce1ecaaf" dependencies = [ "proc-macro2", "quote", @@ -1830,14 +1840,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1930,9 +1941,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", @@ -2094,9 +2105,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" @@ -2217,11 +2228,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2248,6 +2259,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -2394,6 +2414,27 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zeroize" version = "1.8.1" -- cgit v1.2.3 From a979a34b783b4c3a966404c8c7c57aed461fdf91 Mon Sep 17 00:00:00 2001 From: Pi-Cla Date: Sun, 11 Aug 2024 01:33:06 -0600 Subject: Clippy Fixes There are still some clippy warnings left, but this covers most of them --- src/auth.rs | 2 +- src/issues.rs | 26 +++++++++++++------------- src/main.rs | 6 +++--- src/prs.rs | 46 +++++++++++++++++++++++----------------------- src/release.rs | 22 +++++++++++----------- src/repo.rs | 45 ++++++++++++++++++++------------------------- src/user.rs | 10 +++++----- src/wiki.rs | 8 ++++---- 8 files changed, 80 insertions(+), 85 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index 44cb20c..c0bd467 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -58,7 +58,7 @@ impl AuthCommand { Some(key) => key, None => crate::readline("new key: ").await?.trim().to_string(), }; - if keys.hosts.get(&user).is_none() { + if !keys.hosts.contains_key(&user) { keys.hosts.insert( host, crate::keys::LoginInfo::Application { diff --git a/src/issues.rs b/src/issues.rs index a65e3d4..de8822a 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -176,11 +176,11 @@ impl IssueCommand { repo: _, title, body, - } => create_issue(&repo, &api, title, body).await?, + } => create_issue(repo, &api, title, body).await?, View { id, command } => match command.unwrap_or(ViewCommand::Body) { - ViewCommand::Body => view_issue(&repo, &api, id.number).await?, - ViewCommand::Comment { idx } => view_comment(&repo, &api, id.number, idx).await?, - ViewCommand::Comments => view_comments(&repo, &api, id.number).await?, + ViewCommand::Body => view_issue(repo, &api, id.number).await?, + ViewCommand::Comment { idx } => view_comment(repo, &api, id.number, idx).await?, + ViewCommand::Comments => view_comments(repo, &api, id.number).await?, }, Search { repo: _, @@ -189,21 +189,21 @@ impl IssueCommand { creator, assignee, state, - } => view_issues(&repo, &api, query, labels, creator, assignee, state).await?, + } => view_issues(repo, &api, query, labels, creator, assignee, state).await?, Edit { issue, command } => match command { EditCommand::Title { new_title } => { - edit_title(&repo, &api, issue.number, new_title).await? + edit_title(repo, &api, issue.number, new_title).await? } EditCommand::Body { new_body } => { - edit_body(&repo, &api, issue.number, new_body).await? + edit_body(repo, &api, issue.number, new_body).await? } EditCommand::Comment { idx, new_body } => { - edit_comment(&repo, &api, issue.number, idx, new_body).await? + edit_comment(repo, &api, issue.number, idx, new_body).await? } }, - Close { issue, with_msg } => close_issue(&repo, &api, issue.number, with_msg).await?, - Browse { id } => browse_issue(&repo, &api, id.number).await?, - Comment { issue, body } => add_comment(&repo, &api, issue.number, body).await?, + Close { issue, with_msg } => close_issue(repo, &api, issue.number, with_msg).await?, + Browse { id } => browse_issue(repo, &api, id.number).await?, + Comment { issue, body } => add_comment(repo, &api, issue.number, body).await?, } Ok(()) } @@ -408,7 +408,7 @@ pub async fn view_comment(repo: &RepoName, api: &Forgejo, id: u64, idx: usize) - let comment = comments .get(idx) .ok_or_else(|| eyre!("comment {idx} doesn't exist"))?; - print_comment(&comment)?; + print_comment(comment)?; Ok(()) } @@ -440,7 +440,7 @@ fn print_comment(comment: &Comment) -> eyre::Result<()> { .as_ref() .ok_or_else(|| eyre::eyre!("user does not have login"))?; println!("{} said:", username); - println!("{}", crate::markdown(&body)); + println!("{}", crate::markdown(body)); let assets = comment .assets .as_ref() diff --git a/src/main.rs b/src/main.rs index c26081f..8e7ff0e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -159,9 +159,9 @@ async fn editor(contents: &mut String, ext: Option<&str>) -> eyre::Result<()> { file.write_all(contents.as_bytes()).await?; drop(file); - // Closure acting as a try/catch block so that the temp file is deleted even + // Async block acting as a try/catch block so that the temp file is deleted even // on errors - let res = (|| async { + let res = async { eprint!("waiting on editor\r"); let flags = get_editor_flags(&editor); let status = tokio::process::Command::new(editor) @@ -177,7 +177,7 @@ async fn editor(contents: &mut String, ext: Option<&str>) -> eyre::Result<()> { eprint!(" \r"); Ok(()) - })() + } .await; tokio::fs::remove_file(path).await?; diff --git a/src/prs.rs b/src/prs.rs index 840ae12..d66dcf5 100644 --- a/src/prs.rs +++ b/src/prs.rs @@ -274,7 +274,7 @@ impl PrCommand { head, body, repo: _, - } => create_pr(&repo, &api, title, base, head, body).await?, + } => create_pr(repo, &api, title, base, head, body).await?, Merge { pr, method, @@ -283,7 +283,7 @@ impl PrCommand { message, } => { merge_pr( - &repo, + repo, &api, pr.map(|id| id.number), method, @@ -296,26 +296,26 @@ impl PrCommand { View { id, command } => { let id = id.map(|id| id.number); match command.unwrap_or(ViewCommand::Body) { - ViewCommand::Body => view_pr(&repo, &api, id).await?, + ViewCommand::Body => view_pr(repo, &api, id).await?, ViewCommand::Comment { idx } => { - let (repo, id) = try_get_pr_number(&repo, &api, id).await?; + let (repo, id) = try_get_pr_number(repo, &api, id).await?; crate::issues::view_comment(&repo, &api, id, idx).await? } ViewCommand::Comments => { - let (repo, id) = try_get_pr_number(&repo, &api, id).await?; + let (repo, id) = try_get_pr_number(repo, &api, id).await?; crate::issues::view_comments(&repo, &api, id).await? } - ViewCommand::Labels => view_pr_labels(&repo, &api, id).await?, + ViewCommand::Labels => view_pr_labels(repo, &api, id).await?, ViewCommand::Diff { patch, editor } => { - view_diff(&repo, &api, id, patch, editor).await? + view_diff(repo, &api, id, patch, editor).await? } - ViewCommand::Files => view_pr_files(&repo, &api, id).await?, + ViewCommand::Files => view_pr_files(repo, &api, id).await?, ViewCommand::Commits { oneline } => { - view_pr_commits(&repo, &api, id, oneline).await? + view_pr_commits(repo, &api, id, oneline).await? } } } - Status { id } => view_pr_status(&repo, &api, id.map(|id| id.number)).await?, + Status { id } => view_pr_status(repo, &api, id.map(|id| id.number)).await?, Search { query, labels, @@ -323,38 +323,38 @@ impl PrCommand { assignee, state, repo: _, - } => view_prs(&repo, &api, query, labels, creator, assignee, state).await?, + } => view_prs(repo, &api, query, labels, creator, assignee, state).await?, Edit { pr, command } => { let pr = pr.map(|pr| pr.number); match command { EditCommand::Title { new_title } => { - let (repo, id) = try_get_pr_number(&repo, &api, pr).await?; + let (repo, id) = try_get_pr_number(repo, &api, pr).await?; crate::issues::edit_title(&repo, &api, id, new_title).await? } EditCommand::Body { new_body } => { - let (repo, id) = try_get_pr_number(&repo, &api, pr).await?; + let (repo, id) = try_get_pr_number(repo, &api, pr).await?; crate::issues::edit_body(&repo, &api, id, new_body).await? } EditCommand::Comment { idx, new_body } => { - let (repo, id) = try_get_pr_number(&repo, &api, pr).await?; + let (repo, id) = try_get_pr_number(repo, &api, pr).await?; crate::issues::edit_comment(&repo, &api, id, idx, new_body).await? } EditCommand::Labels { add, rm } => { - edit_pr_labels(&repo, &api, pr, add, rm).await? + edit_pr_labels(repo, &api, pr, add, rm).await? } } } Close { pr, with_msg } => { - let (repo, pr) = try_get_pr_number(&repo, &api, pr.map(|pr| pr.number)).await?; + let (repo, pr) = try_get_pr_number(repo, &api, pr.map(|pr| pr.number)).await?; crate::issues::close_issue(&repo, &api, pr, with_msg).await? } - Checkout { pr, branch_name } => checkout_pr(&repo, &api, pr, branch_name).await?, + Checkout { pr, branch_name } => checkout_pr(repo, &api, pr, branch_name).await?, Browse { id } => { - let (repo, id) = try_get_pr_number(&repo, &api, id.map(|pr| pr.number)).await?; + let (repo, id) = try_get_pr_number(repo, &api, id.map(|pr| pr.number)).await?; browse_pr(&repo, &api, id).await? } Comment { pr, body } => { - let (repo, pr) = try_get_pr_number(&repo, &api, pr.map(|pr| pr.number)).await?; + let (repo, pr) = try_get_pr_number(repo, &api, pr.map(|pr| pr.number)).await?; crate::issues::add_comment(&repo, &api, pr, body).await? } } @@ -747,7 +747,7 @@ async fn edit_pr_labels( for label_name in &add { let maybe_label = labels .iter() - .find(|label| label.name.as_ref() == Some(&label_name)); + .find(|label| label.name.as_ref() == Some(label_name)); if let Some(label) = maybe_label { add_ids.push(serde_json::Value::Number( label.id.ok_or_eyre("label does not have id")?.into(), @@ -761,7 +761,7 @@ async fn edit_pr_labels( for label_name in &rm { let maybe_label = labels .iter() - .find(|label| label.name.as_ref() == Some(&label_name)); + .find(|label| label.name.as_ref() == Some(label_name)); if let Some(label) = maybe_label { rm_ids.push(label.id.ok_or_eyre("label does not have id")?); } else { @@ -865,7 +865,7 @@ async fn create_pr( let (base, base_is_parent) = match base { Some(base) => match base.strip_prefix("^") { - Some(stripped) if stripped.is_empty() => (None, true), + Some("") => (None, true), Some(stripped) => (Some(stripped.to_owned()), true), None => (Some(base), false), }, @@ -1291,7 +1291,7 @@ async fn view_pr_commits( .ok_or_eyre("commit does not have commit?")?; let message = repo_commit.message.as_deref().unwrap_or("[no msg]"); - let name = message.lines().next().unwrap_or(&message); + let name = message.lines().next().unwrap_or(message); let sha = commit .sha diff --git a/src/release.rs b/src/release.rs index fa9d7d7..49dd5b5 100644 --- a/src/release.rs +++ b/src/release.rs @@ -127,7 +127,7 @@ pub enum AssetCommand { impl ReleaseCommand { pub async fn run(self, keys: &mut KeyInfo, remote_name: Option<&str>) -> eyre::Result<()> { let repo = RepoInfo::get_current(remote_name, self.repo.as_ref(), self.remote.as_deref())?; - let api = keys.get_api(&repo.host_url()).await?; + let api = keys.get_api(repo.host_url()).await?; let repo = repo .name() .ok_or_eyre("couldn't get repo name, try specifying with --repo")?; @@ -143,7 +143,7 @@ impl ReleaseCommand { prerelease, } => { create_release( - &repo, &api, name, create_tag, tag, attach, body, branch, draft, prerelease, + repo, &api, name, create_tag, tag, attach, body, branch, draft, prerelease, ) .await? } @@ -154,32 +154,32 @@ impl ReleaseCommand { body, draft, prerelease, - } => edit_release(&repo, &api, name, rename, tag, body, draft, prerelease).await?, + } => edit_release(repo, &api, name, rename, tag, body, draft, prerelease).await?, ReleaseSubcommand::Delete { name, by_tag } => { - delete_release(&repo, &api, name, by_tag).await? + delete_release(repo, &api, name, by_tag).await? } ReleaseSubcommand::List { include_prerelease, include_draft, - } => list_releases(&repo, &api, include_prerelease, include_draft).await?, + } => list_releases(repo, &api, include_prerelease, include_draft).await?, ReleaseSubcommand::View { name, by_tag } => { - view_release(&repo, &api, name, by_tag).await? + view_release(repo, &api, name, by_tag).await? } - ReleaseSubcommand::Browse { name } => browse_release(&repo, &api, name).await?, + ReleaseSubcommand::Browse { name } => browse_release(repo, &api, name).await?, ReleaseSubcommand::Asset(subcommand) => match subcommand { AssetCommand::Create { release, path, name, - } => create_asset(&repo, &api, release, path, name).await?, + } => create_asset(repo, &api, release, path, name).await?, AssetCommand::Delete { release, asset } => { - delete_asset(&repo, &api, release, asset).await? + delete_asset(repo, &api, release, asset).await? } AssetCommand::Download { release, asset, output, - } => download_asset(&repo, &api, release, asset, output).await?, + } => download_asset(repo, &api, release, asset, output).await?, }, } Ok(()) @@ -394,7 +394,7 @@ async fn view_release( .ok_or_else(|| eyre::eyre!("release does not have body"))?; if !body.is_empty() { println!(); - println!("{}", crate::markdown(&body)); + println!("{}", crate::markdown(body)); println!(); } let assets = release diff --git a/src/repo.rs b/src/repo.rs index dce5487..07370d3 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -95,7 +95,7 @@ impl RepoInfo { remote_name.as_str().ok_or_eyre("remote name invalid")?; if let Some(host_url) = &host_url { - let remote = local_repo.find_remote(&remote_name_s)?; + let remote = local_repo.find_remote(remote_name_s)?; let url_s = std::str::from_utf8(remote.url_bytes())?; let url = Url::parse(url_s)?; @@ -154,14 +154,12 @@ impl RepoInfo { (repo_url, repo_name) } else if repo_name.is_some() { (host_url.or(remote_url), repo_name) + } else if remote.is_some() { + (remote_url, remote_repo_name) + } else if host_url.is_none() || remote_url == host_url { + (remote_url, remote_repo_name) } else { - if remote.is_some() { - (remote_url, remote_repo_name) - } else if host_url.is_none() || remote_url == host_url { - (remote_url, remote_repo_name) - } else { - (host_url, None) - } + (host_url, None) }; let url = url.or_else(fallback_host); @@ -377,17 +375,14 @@ impl RepoCommand { let no_trailing_slash = no_scheme.strip_suffix("/").unwrap_or(no_scheme); no_trailing_slash } - match (repo.host.as_deref(), host_name) { - (Some(a), Some(b)) => { - if strip(a) != strip(b) { - eyre::bail!("conflicting hosts {a} and {b}. please only specify one"); - } + if let (Some(a), Some(b)) = (repo.host.as_deref(), host_name) { + if strip(a) != strip(b) { + eyre::bail!("conflicting hosts {a} and {b}. please only specify one"); } - _ => (), } let repo_info = RepoInfo::get_current(host_name, Some(&repo), remote.as_deref())?; - let api = keys.get_api(&repo_info.host_url()).await?; + let api = keys.get_api(repo_info.host_url()).await?; let repo = repo_info .name() .ok_or_eyre("couldn't get repo name, please specify")?; @@ -395,28 +390,28 @@ impl RepoCommand { } RepoCommand::View { name, remote } => { let repo = RepoInfo::get_current(host_name, name.as_ref(), remote.as_deref())?; - let api = keys.get_api(&repo.host_url()).await?; + let api = keys.get_api(repo.host_url()).await?; let repo = repo .name() .ok_or_eyre("couldn't get repo name, please specify")?; - view_repo(&api, &repo).await? + view_repo(&api, repo).await? } RepoCommand::Clone { repo, path } => { let repo = RepoInfo::get_current(host_name, Some(&repo), None)?; - let api = keys.get_api(&repo.host_url()).await?; + let api = keys.get_api(repo.host_url()).await?; let name = repo.name().unwrap(); - cmd_clone_repo(&api, &name, path).await?; + cmd_clone_repo(&api, name, path).await?; } RepoCommand::Star { repo } => { let repo = RepoInfo::get_current(host_name, Some(&repo), None)?; - let api = keys.get_api(&repo.host_url()).await?; + let api = keys.get_api(repo.host_url()).await?; let name = repo.name().unwrap(); api.user_current_put_star(name.owner(), name.name()).await?; println!("Starred {}/{}!", name.owner(), name.name()); } RepoCommand::Unstar { repo } => { let repo = RepoInfo::get_current(host_name, Some(&repo), None)?; - let api = keys.get_api(&repo.host_url()).await?; + let api = keys.get_api(repo.host_url()).await?; let name = repo.name().unwrap(); api.user_current_delete_star(name.owner(), name.name()) .await?; @@ -424,9 +419,9 @@ impl RepoCommand { } RepoCommand::Delete { repo } => { let repo = RepoInfo::get_current(host_name, Some(&repo), None)?; - let api = keys.get_api(&repo.host_url()).await?; + let api = keys.get_api(repo.host_url()).await?; let name = repo.name().unwrap(); - delete_repo(&api, &name).await?; + delete_repo(&api, name).await?; } RepoCommand::Browse { name, remote } => { let repo = RepoInfo::get_current(host_name, name.as_ref(), remote.as_deref())?; @@ -668,7 +663,7 @@ async fn cmd_clone_repo( let path = path.unwrap_or_else(|| PathBuf::from(format!("./{repo_name}"))); - let local_repo = clone_repo(&repo_full_name, &clone_url, &path)?; + let local_repo = clone_repo(repo_full_name, clone_url, &path)?; if let Some(parent) = repo_data.parent.as_deref() { let parent_clone_url = parent @@ -740,7 +735,7 @@ pub fn clone_repo( let local_repo = git2::build::RepoBuilder::new() .fetch_options(options) - .clone(url.as_str(), &path)?; + .clone(url.as_str(), path)?; if fancy { print!("{clear_line}{show_cursor}\r"); } diff --git a/src/user.rs b/src/user.rs index d38d8b5..6f7de40 100644 --- a/src/user.rs +++ b/src/user.rs @@ -685,12 +685,12 @@ async fn list_activity(api: &Forgejo, user: Option<&str>) -> eyre::Result<()> { .as_deref() .ok_or_eyre("parent repo does not have full name")?; println!("{bold}{actor_name}{reset} forked repository {bold}{yellow}{parent_full_name}{reset} to {bold}{yellow}{full_name}{reset}"); + } else if repo.mirror.is_some_and(|b| b) { + println!( + "{bold}{actor_name}{reset} created mirror {bold}{yellow}{full_name}{reset}" + ); } else { - if repo.mirror.is_some_and(|b| b) { - println!("{bold}{actor_name}{reset} created mirror {bold}{yellow}{full_name}{reset}"); - } else { - println!("{bold}{actor_name}{reset} created repository {bold}{yellow}{full_name}{reset}"); - } + println!("{bold}{actor_name}{reset} created repository {bold}{yellow}{full_name}{reset}"); } } ActivityOpType::RenameRepo => { diff --git a/src/wiki.rs b/src/wiki.rs index 63d344f..616789d 100644 --- a/src/wiki.rs +++ b/src/wiki.rs @@ -52,10 +52,10 @@ impl WikiCommand { .ok_or_else(|| eyre::eyre!("couldn't guess repo"))?; match self.command { - Contents { repo: _ } => wiki_contents(&repo, &api).await?, - View { repo: _, page } => view_wiki_page(&repo, &api, &*page).await?, - Clone { repo: _, path } => clone_wiki(&repo, &api, path).await?, - Browse { repo: _, page } => browse_wiki_page(&repo, &api, &*page).await?, + Contents { repo: _ } => wiki_contents(repo, &api).await?, + View { repo: _, page } => view_wiki_page(repo, &api, &page).await?, + Clone { repo: _, path } => clone_wiki(repo, &api, path).await?, + Browse { repo: _, page } => browse_wiki_page(repo, &api, &page).await?, } Ok(()) } -- cgit v1.2.3