Skip to content

chore: format module imports for readability #1183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 13 additions & 30 deletions git-cliff-core/src/changelog.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
use std::collections::HashMap;
use std::io::{Read, Write};
use std::time::{SystemTime, UNIX_EPOCH};

use crate::commit::Commit;
use crate::config::{
Config,
GitConfig,
};
use crate::error::{
Error,
Result,
};
use crate::release::{
Release,
Releases,
};
use crate::config::{Config, GitConfig};
use crate::error::{Error, Result};
use crate::release::{Release, Releases};
#[cfg(feature = "bitbucket")]
use crate::remote::bitbucket::BitbucketClient;
#[cfg(feature = "gitea")]
Expand All @@ -20,15 +15,6 @@ use crate::remote::github::GitHubClient;
#[cfg(feature = "gitlab")]
use crate::remote::gitlab::GitLabClient;
use crate::template::Template;
use std::collections::HashMap;
use std::io::{
Read,
Write,
};
use std::time::{
SystemTime,
UNIX_EPOCH,
};

/// Changelog generator.
#[derive(Debug)]
Expand Down Expand Up @@ -697,18 +683,15 @@ fn get_body_template(config: &Config, trim: bool) -> Result<Template> {

#[cfg(test)]
mod test {
use std::str;

use pretty_assertions::assert_eq;
use regex::Regex;

use super::*;
use crate::config::{
Bump,
ChangelogConfig,
CommitParser,
Remote,
RemoteConfig,
TextProcessor,
Bump, ChangelogConfig, CommitParser, Remote, RemoteConfig, TextProcessor,
};
use pretty_assertions::assert_eq;
use regex::Regex;
use std::str;

fn get_test_data() -> (Config, Vec<Release<'static>>) {
let config = Config {
Expand Down
17 changes: 4 additions & 13 deletions git-cliff-core/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
use std::io::{Error as IoError, Write};
use std::process::{Command, Stdio};
use std::{env, str, thread};

use crate::error::Result;
use std::io::{
Error as IoError,
Write,
};
use std::process::{
Command,
Stdio,
};
use std::thread;
use std::{
env,
str,
};

/// Runs the given OS command and returns the output as string.
///
Expand Down
40 changes: 8 additions & 32 deletions git-cliff-core/src/commit.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
use crate::config::{
CommitParser,
GitConfig,
LinkParser,
TextProcessor,
};
use crate::error::{
Error as AppError,
Result,
};
use git_conventional::{
Commit as ConventionalCommit,
Footer as ConventionalFooter,
};
use git_conventional::{Commit as ConventionalCommit, Footer as ConventionalFooter};
#[cfg(feature = "repo")]
use git2::{
Commit as GitCommit,
Signature as CommitSignature,
};
use lazy_regex::{
Lazy,
Regex,
lazy_regex,
};
use serde::ser::{
SerializeStruct,
Serializer,
};
use serde::{
Deserialize,
Deserializer,
Serialize,
};
use git2::{Commit as GitCommit, Signature as CommitSignature};
use lazy_regex::{Lazy, Regex, lazy_regex};
use serde::ser::{SerializeStruct, Serializer};
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::value::Value;

use crate::config::{CommitParser, GitConfig, LinkParser, TextProcessor};
use crate::error::{Error as AppError, Result};

/// Regular expression for matching SHA1 and a following commit message
/// separated by a whitespace.
static SHA1_REGEX: Lazy<Regex> = lazy_regex!(r#"^\b([a-f0-9]{40})\b (.*)$"#);
Expand Down
37 changes: 14 additions & 23 deletions git-cliff-core/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
use crate::embed::EmbeddedConfig;
use crate::error::Result;
use crate::{
command,
error,
};
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::{fmt, fs};

use glob::Pattern;
use regex::{
Regex,
RegexBuilder,
};
use regex::{Regex, RegexBuilder};
use secrecy::SecretString;
use serde::{
Deserialize,
Serialize,
};
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::{
fmt,
str::FromStr,
};
use serde::{Deserialize, Serialize};

use crate::embed::EmbeddedConfig;
use crate::error::Result;
use crate::{command, error};

/// Default initial tag.
const DEFAULT_INITIAL_TAG: &str = "0.1.0";
Expand Down Expand Up @@ -525,9 +514,11 @@ impl FromStr for Config {

#[cfg(test)]
mod test {
use super::*;
use pretty_assertions::assert_eq;
use std::env;

use pretty_assertions::assert_eq;

use super::*;
#[test]
fn load() -> Result<()> {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
Expand Down
11 changes: 3 additions & 8 deletions git-cliff-core/src/contributor.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use serde::{
Deserialize,
Serialize,
};
use std::hash::{
Hash,
Hasher,
};
use std::hash::{Hash, Hasher};

use serde::{Deserialize, Serialize};

/// Representation of a remote contributor.
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
Expand Down
11 changes: 5 additions & 6 deletions git-cliff-core/src/embed.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::config::Config;
use crate::error::{
Error,
Result,
};
use rust_embed::RustEmbed;
use std::path::Path;
use std::str;

use rust_embed::RustEmbed;

use crate::config::Config;
use crate::error::{Error, Result};

/// Default configuration file embedder/extractor.
///
/// Embeds `config/`[`DEFAULT_CONFIG`] into the binary.
Expand Down
6 changes: 2 additions & 4 deletions git-cliff-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,9 @@ pub type Result<T> = core::result::Result<T, Error>;

#[cfg(test)]
mod test {
use git_conventional::{Commit, ErrorKind};

use super::*;
use git_conventional::{
Commit,
ErrorKind,
};
fn mock_function() -> super::Result<Commit<'static>> {
Ok(Commit::parse("test")?)
}
Expand Down
59 changes: 15 additions & 44 deletions git-cliff-core/src/release.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
use std::collections::HashMap;

use crate::commit::commits_to_conventional_commits;
use next_version::{NextVersion, VersionUpdater};
use semver::Version;
use serde::{Deserialize, Serialize};
use serde_json::value::Value;

use crate::commit::{Commit, Range, commits_to_conventional_commits};
use crate::config::{Bump, BumpType};
use crate::error::Result;
use crate::{
commit::{
Commit,
Range,
},
config::Bump,
config::BumpType,
};
#[cfg(feature = "remote")]
use crate::{
contributor::RemoteContributor,
remote::{
RemoteCommit,
RemotePullRequest,
RemoteReleaseMetadata,
},
};

use next_version::{
NextVersion,
VersionUpdater,
remote::{RemoteCommit, RemotePullRequest, RemoteReleaseMetadata},
};
use semver::Version;
use serde::{
Deserialize,
Serialize,
};
use serde_json::value::Value;

/// Representation of a release.
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -195,8 +178,9 @@ impl Releases<'_> {

#[cfg(test)]
mod test {
use super::*;
use pretty_assertions::assert_eq;

use super::*;
#[test]
fn bump_version() -> Result<()> {
fn build_release<'a>(version: &str, commits: &'a [&str]) -> Release<'a> {
Expand Down Expand Up @@ -392,12 +376,8 @@ mod test {
#[test]
fn update_github_metadata() -> Result<()> {
use crate::remote::github::{
GitHubCommit,
GitHubCommitAuthor,
GitHubCommitDetails,
GitHubCommitDetailsAuthor,
GitHubPullRequest,
PullRequestLabel,
GitHubCommit, GitHubCommitAuthor, GitHubCommitDetails,
GitHubCommitDetailsAuthor, GitHubPullRequest, PullRequestLabel,
};

let mut release = Release {
Expand Down Expand Up @@ -764,11 +744,7 @@ mod test {
#[cfg(feature = "gitlab")]
#[test]
fn update_gitlab_metadata() -> Result<()> {
use crate::remote::gitlab::{
GitLabCommit,
GitLabMergeRequest,
GitLabUser,
};
use crate::remote::gitlab::{GitLabCommit, GitLabMergeRequest, GitLabUser};

let mut release = Release {
version: None,
Expand Down Expand Up @@ -1156,10 +1132,7 @@ mod test {
#[test]
fn update_gitea_metadata() -> Result<()> {
use crate::remote::gitea::{
GiteaCommit,
GiteaCommitAuthor,
GiteaPullRequest,
PullRequestLabel,
GiteaCommit, GiteaCommitAuthor, GiteaPullRequest, PullRequestLabel,
};

let mut release = Release {
Expand Down Expand Up @@ -1516,9 +1489,7 @@ mod test {
#[test]
fn update_bitbucket_metadata() -> Result<()> {
use crate::remote::bitbucket::{
BitbucketCommit,
BitbucketCommitAuthor,
BitbucketPullRequest,
BitbucketCommit, BitbucketCommitAuthor, BitbucketPullRequest,
BitbucketPullRequestMergeCommit,
};

Expand Down
12 changes: 5 additions & 7 deletions git-cliff-core/src/remote/bitbucket.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use crate::config::Remote;
use crate::error::*;
use reqwest_middleware::ClientWithMiddleware;
use serde::{
Deserialize,
Serialize,
};
use serde::{Deserialize, Serialize};

use super::*;
use crate::config::Remote;
use crate::error::*;

/// Log message to show while fetching data from Bitbucket.
pub const START_FETCHING_MSG: &str = "Retrieving data from Bitbucket...";
Expand Down Expand Up @@ -246,9 +243,10 @@ impl BitbucketClient {

#[cfg(test)]
mod test {
use pretty_assertions::assert_eq;

use super::*;
use crate::remote::RemoteCommit;
use pretty_assertions::assert_eq;

#[test]
fn timestamp() {
Expand Down
12 changes: 5 additions & 7 deletions git-cliff-core/src/remote/gitea.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use crate::config::Remote;
use crate::error::*;
use reqwest_middleware::ClientWithMiddleware;
use serde::{
Deserialize,
Serialize,
};
use serde::{Deserialize, Serialize};

use super::*;
use crate::config::Remote;
use crate::error::*;

/// Log message to show while fetching data from Gitea.
pub const START_FETCHING_MSG: &str = "Retrieving data from Gitea...";
Expand Down Expand Up @@ -205,9 +202,10 @@ impl GiteaClient {

#[cfg(test)]
mod test {
use pretty_assertions::assert_eq;

use super::*;
use crate::remote::RemoteCommit;
use pretty_assertions::assert_eq;

#[test]
fn timestamp() {
Expand Down
Loading
Loading