Skip to content

Commit

Permalink
style: Address warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed May 2, 2024
1 parent ca43bec commit dee9d3d
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 24 deletions.
File renamed without changes.
4 changes: 1 addition & 3 deletions src/ops/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ pub fn package_content(manifest_path: &Path) -> CargoResult<Vec<std::path::PathB
cmd.arg("--allow-dirty");
let output = cmd.output()?;

let parent = manifest_path
.parent()
.unwrap_or_else(|| std::path::Path::new(""));
let parent = manifest_path.parent().unwrap_or_else(|| Path::new(""));

if output.status.success() {
let paths = ByteSlice::lines(output.stdout.as_slice())
Expand Down
2 changes: 1 addition & 1 deletion src/ops/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub fn git_version() -> CargoResult<()> {
#[cfg(unix)]
pub fn bytes2path(b: &[u8]) -> &Path {
use std::os::unix::prelude::OsStrExt;
std::path::Path::new(std::ffi::OsStr::from_bytes(b))
Path::new(std::ffi::OsStr::from_bytes(b))
}

// From git2 crate
Expand Down
2 changes: 1 addition & 1 deletion src/ops/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl RemoteIndex {
{
if let Ok(etag) = etag.to_str() {
if let Some(i) = self.etags.iter().position(|(krate, _)| krate == name) {
self.etags[i].1 = etag.to_owned();
etag.clone_into(&mut self.etags[i].1);
} else {
self.etags.push((name.to_owned(), etag.to_owned()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/steps/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub fn changes(
let unbumped = pkg
.planned_tag
.as_deref()
.and_then(|t| crate::ops::git::tag_exists(workspace_root, t).ok())
.and_then(|t| git::tag_exists(workspace_root, t).ok())
.unwrap_or(false);
let bumped = !unbumped;
if let Some(max_status) = max_status {
Expand Down
10 changes: 5 additions & 5 deletions src/steps/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct CommitStep {
no_confirm: bool,

#[command(flatten)]
commit: crate::config::CommitArgs,
commit: config::CommitArgs,
}

impl CommitStep {
Expand All @@ -55,7 +55,7 @@ impl CommitStep {
.features(cargo_metadata::CargoOpt::AllFeatures)
.exec()?;
let config = self.to_config();
let ws_config = crate::config::load_workspace_config(&config, &ws_meta)?;
let ws_config = config::load_workspace_config(&config, &ws_meta)?;
let pkgs = plan::load(&config, &ws_meta)?;

let pkgs = plan::plan(pkgs)?;
Expand All @@ -64,7 +64,7 @@ impl CommitStep {
.into_iter()
.map(|(_, pkg)| pkg)
.partition(|p| p.config.release());
if crate::ops::git::is_dirty(ws_meta.workspace_root.as_std_path())?.is_none() {
if git::is_dirty(ws_meta.workspace_root.as_std_path())?.is_none() {
let _ = crate::ops::shell::error("nothing to commit");
return Err(2.into());
}
Expand Down Expand Up @@ -108,8 +108,8 @@ impl CommitStep {
super::finish(failed, dry_run)
}

fn to_config(&self) -> crate::config::ConfigArgs {
crate::config::ConfigArgs {
fn to_config(&self) -> config::ConfigArgs {
config::ConfigArgs {
custom_config: self.custom_config.clone(),
isolated: self.isolated,
allow_branch: self.allow_branch.clone(),
Expand Down
4 changes: 1 addition & 3 deletions src/steps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,7 @@ pub fn warn_changed(
let version = pkg.planned_version.as_ref().unwrap_or(&pkg.initial_version);
let crate_name = pkg.meta.name.as_str();
if let Some(prior_tag_name) = &pkg.prior_tag {
if let Some(changed) =
crate::steps::version::changed_since(ws_meta, pkg, prior_tag_name)
{
if let Some(changed) = version::changed_since(ws_meta, pkg, prior_tag_name) {
if !changed.is_empty() {
log::debug!(
"Files changed in {} since {}: {:#?}",
Expand Down
12 changes: 6 additions & 6 deletions src/steps/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl PackageRelease {
&initial_version,
&initial_version,
);
let prior_tag = if crate::ops::git::tag_exists(&package_root, &initial_tag)? {
let prior_tag = if git::tag_exists(&package_root, &initial_tag)? {
Some(initial_tag)
} else {
let tag_name = config.tag_name();
Expand All @@ -166,7 +166,7 @@ impl PackageRelease {
match globset::Glob::new(&tag_glob) {
Ok(tag_glob) => {
let tag_glob = tag_glob.compile_matcher();
crate::ops::git::find_last_tag(&package_root, &tag_glob)
git::find_last_tag(&package_root, &tag_glob)
}
Err(err) => {
log::debug!("failed to find tag with glob `{}`: {}", tag_glob, err);
Expand Down Expand Up @@ -211,22 +211,22 @@ impl PackageRelease {
mut metadata: Option<&'s str>,
) -> CargoResult<()> {
match self.config.metadata() {
crate::config::MetadataPolicy::Optional => {}
crate::config::MetadataPolicy::Required => {
config::MetadataPolicy::Optional => {}
config::MetadataPolicy::Required => {
if metadata.is_none() {
anyhow::bail!(
"`{}` requires the metadata to be overridden",
self.meta.name
)
}
}
crate::config::MetadataPolicy::Ignore => {
config::MetadataPolicy::Ignore => {
if let Some(metadata) = metadata {
log::debug!("ignoring metadata `{}` for `{}`", metadata, self.meta.name);
}
metadata = None;
}
crate::config::MetadataPolicy::Persistent => {
config::MetadataPolicy::Persistent => {
let initial_metadata = &self.initial_version.full_version.build;
if !initial_metadata.is_empty() {
metadata.get_or_insert(initial_metadata.as_str());
Expand Down
2 changes: 1 addition & 1 deletion src/steps/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub fn push(
) -> Result<(), CliError> {
if ws_config.push() {
let git_remote = ws_config.push_remote();
let branch = crate::ops::git::current_branch(ws_meta.workspace_root.as_std_path())?;
let branch = git::current_branch(ws_meta.workspace_root.as_std_path())?;

let mut shared_refs = HashSet::new();
for pkg in pkgs {
Expand Down
4 changes: 2 additions & 2 deletions src/steps/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct ReleaseStep {
prev_tag_name: Option<String>,

#[command(flatten)]
config: crate::config::ConfigArgs,
config: config::ConfigArgs,
}

impl ReleaseStep {
Expand Down Expand Up @@ -259,7 +259,7 @@ impl ReleaseStep {
log::debug!("updating lock file");
if !dry_run {
let workspace_path = ws_meta.workspace_root.as_std_path().join("Cargo.toml");
crate::ops::cargo::update_lock(&workspace_path)?;
cargo::update_lock(&workspace_path)?;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/steps/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl TagStep {

for pkg in pkgs.values_mut() {
if let Some(tag_name) = pkg.planned_tag.as_ref() {
if crate::ops::git::tag_exists(ws_meta.workspace_root.as_std_path(), tag_name)? {
if git::tag_exists(ws_meta.workspace_root.as_std_path(), tag_name)? {
let crate_name = pkg.meta.name.as_str();
let _ = crate::ops::shell::warn(format!(
"disabled due to existing tag ({}), skipping {}",
Expand Down

0 comments on commit dee9d3d

Please sign in to comment.