Skip to content

Commit

Permalink
Satisfy rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
radusuciu committed Mar 10, 2023
1 parent e8bd872 commit 0797bfa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions git-cliff-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const CARGO_METADATA_REGEX: &str =
r"^\[(?:workspace|package)\.metadata\.git\-cliff\.";

/// Regex for matching the metadata in pyproject.toml
const PYPROJECT_METADATA_REGEX: &str =
r"^\[(?:tool)\.git\-cliff\.";
const PYPROJECT_METADATA_REGEX: &str = r"^\[(?:tool)\.git\-cliff\.";

/// Configuration values.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -123,15 +122,19 @@ pub struct LinkParser {
impl Config {
/// Parses the config file and returns the values.
pub fn parse(path: &Path) -> Result<Config> {
let config_builder = if path.file_name() == Some(OsStr::new("Cargo.toml")) || path.file_name() == Some(OsStr::new("pyproject.toml")) {
let config_builder = if path.file_name() == Some(OsStr::new("Cargo.toml")) ||
path.file_name() == Some(OsStr::new("pyproject.toml"))
{
let contents = fs::read_to_string(path)?;
let metadata_regex = RegexBuilder::new(if path.file_name() == Some(OsStr::new("Cargo.toml")) {
let metadata_regex = RegexBuilder::new(
if path.file_name() == Some(OsStr::new("Cargo.toml")) {
CARGO_METADATA_REGEX
} else {
PYPROJECT_METADATA_REGEX
})
.multi_line(true)
.build()?;
},
)
.multi_line(true)
.build()?;
let contents = metadata_regex.replace_all(&contents, "[");
config::Config::builder().add_source(config::File::from_str(
&contents,
Expand Down

0 comments on commit 0797bfa

Please sign in to comment.