diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 388b55a..3db8ca5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: - uses: 'actions/checkout@v4' - uses: 'Swatinem/rust-cache@v2' - name: 'Run formatter' - run: cargo fmt --all --check + run: cargo +nightly fmt --all --check - name: 'Run linter' run: cargo clippy --workspace --all-targets --all-features --locked test: diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..4d02947 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,3 @@ +group_imports = "StdExternalCrate" +imports_granularity = "Module" +unstable_features = true diff --git a/src/commands/info.rs b/src/commands/info.rs index 029f6f4..7302621 100644 --- a/src/commands/info.rs +++ b/src/commands/info.rs @@ -1,12 +1,12 @@ /* 'info' command displays data from config-file. */ -use crate::versioning; -use crate::workspace::Workspace; - use anyhow::Result; use clap::Args; use tera::{Context, Tera}; +use crate::versioning; +use crate::workspace::Workspace; + #[derive(Args)] pub(crate) struct Arguments {} diff --git a/src/commands/init.rs b/src/commands/init.rs index 9b62893..2bb5886 100644 --- a/src/commands/init.rs +++ b/src/commands/init.rs @@ -1,13 +1,14 @@ -use crate::config; -use crate::config::age_toml; -use anyhow::{anyhow, Result}; use std::env::current_dir; use std::fs::File; use std::io::prelude::*; +use anyhow::{anyhow, Result}; use clap::Args; use tera::{Context, Tera}; +use crate::config; +use crate::config::age_toml; + const TEMPLATE_BASE: &'static str = r#" current_version = "{{ current_version }}" diff --git a/src/commands/major.rs b/src/commands/major.rs index c3edf83..07cc4b8 100644 --- a/src/commands/major.rs +++ b/src/commands/major.rs @@ -1,8 +1,9 @@ -use crate::versioning::up_major; -use crate::workspace::{make_context, Workspace}; use anyhow::Result; use clap::Args; +use crate::versioning::up_major; +use crate::workspace::{make_context, Workspace}; + #[derive(Args)] pub(crate) struct Arguments {} diff --git a/src/commands/minor.rs b/src/commands/minor.rs index 42d4da6..ad4f836 100644 --- a/src/commands/minor.rs +++ b/src/commands/minor.rs @@ -1,8 +1,9 @@ -use crate::versioning::up_minor; -use crate::workspace::{make_context, Workspace}; use anyhow::Result; use clap::Args; +use crate::versioning::up_minor; +use crate::workspace::{make_context, Workspace}; + #[derive(Args)] pub(crate) struct Arguments {} diff --git a/src/commands/patch.rs b/src/commands/patch.rs index 603d55f..a381320 100644 --- a/src/commands/patch.rs +++ b/src/commands/patch.rs @@ -1,8 +1,9 @@ -use crate::versioning::up_patch; -use crate::workspace::{make_context, Workspace}; use anyhow::Result; use clap::Args; +use crate::versioning::up_patch; +use crate::workspace::{make_context, Workspace}; + #[derive(Args)] pub(crate) struct Arguments {} diff --git a/src/commands/update.rs b/src/commands/update.rs index ed682f2..329f1d6 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -1,8 +1,9 @@ -use crate::workspace::{make_context, Workspace}; use anyhow::Result; use clap::Args; use semver::Version; +use crate::workspace::{make_context, Workspace}; + #[derive(Args)] pub(crate) struct Arguments { new_version: Version, diff --git a/src/config.rs b/src/config.rs index 63515f6..6abfc06 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,10 +1,11 @@ // Configuration manager. +use std::path::PathBuf; + use anyhow::{anyhow, Result}; use log::info; use semver::Version; use serde::{Deserialize, Serialize}; -use std::path::PathBuf; pub mod age_toml; mod cargo_toml; diff --git a/src/config/age_toml.rs b/src/config/age_toml.rs index 6a2d486..e0ef9a3 100644 --- a/src/config/age_toml.rs +++ b/src/config/age_toml.rs @@ -3,7 +3,8 @@ use std::io::prelude::*; use std::path::PathBuf; use anyhow::{anyhow, Result}; -use toml_edit::{de::from_document, value, DocumentMut}; +use toml_edit::de::from_document; +use toml_edit::{value, DocumentMut}; use super::{Config, ParseAvailable}; diff --git a/src/config/cargo_toml.rs b/src/config/cargo_toml.rs index 2cbc56f..49504de 100644 --- a/src/config/cargo_toml.rs +++ b/src/config/cargo_toml.rs @@ -3,7 +3,8 @@ use std::io::prelude::*; use std::path::PathBuf; use anyhow::{anyhow, Result}; -use toml::{de::Error, Table}; +use toml::de::Error; +use toml::Table; use toml_edit::{value, DocumentMut}; use super::{Config, ParseAvailable}; diff --git a/src/config/pyproject_toml.rs b/src/config/pyproject_toml.rs index 7449999..8832dd7 100644 --- a/src/config/pyproject_toml.rs +++ b/src/config/pyproject_toml.rs @@ -3,7 +3,8 @@ use std::io::prelude::*; use std::path::PathBuf; use anyhow::{anyhow, Result}; -use toml::{de::Error, Table}; +use toml::de::Error; +use toml::Table; use toml_edit::{value, DocumentMut}; use super::{Config, ParseAvailable}; diff --git a/src/main.rs b/src/main.rs index ee65341..fee0944 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,11 @@ // Entry point. +use crate::commands::run_command; + mod commands; mod config; mod versioning; mod workspace; mod writer; -use crate::commands::run_command; fn main() { env_logger::init(); diff --git a/src/workspace.rs b/src/workspace.rs index 09ec74f..94c61d8 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -1,8 +1,9 @@ +use std::path::PathBuf; + use anyhow::{anyhow, Result}; use chrono::{DateTime, Local}; use log::debug; use semver::Version; -use std::path::PathBuf; use crate::config::{resolve_config, Config, ConfigDocument}; use crate::writer::Writer; diff --git a/src/writer.rs b/src/writer.rs index 80e156d..32ee69a 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -119,10 +119,10 @@ impl WriteRule { #[cfg(test)] mod tests { - use super::*; - use semver::Version; + use super::*; + #[test] fn new_writer() { let ctx = Context::new();