Mercurial > hg
view rust/rhg/src/commands/root.rs @ 51120:532e74ad3ff6
rust: run a clippy pass with the latest stable version
Our current version of clippy is older than the latest stable.
The newest version has new lints that are moslty good advice, so let's apply
them ahead of time. This has the added benefit of reducing the noise for
developpers like myself that use clippy as an IDE helper, as well as being
more prepared for a future clippy upgrade.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 06 Nov 2023 11:06:08 +0100 |
parents | 37bc3edef76f |
children |
line wrap: on
line source
use crate::error::CommandError; use format_bytes::format_bytes; use hg::errors::{IoErrorContext, IoResultExt}; use hg::utils::files::get_bytes_from_path; pub const HELP_TEXT: &str = " Print the root directory of the current repository. Returns 0 on success. "; pub fn args() -> clap::Command { clap::command!("root").about(HELP_TEXT) } pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { let repo = invocation.repo?; let working_directory = repo.working_directory_path(); let working_directory = std::fs::canonicalize(working_directory) .with_context(|| { IoErrorContext::CanonicalizingPath(working_directory.to_owned()) })?; let bytes = get_bytes_from_path(working_directory); invocation .ui .write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?; Ok(()) }