Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Jan 28, 2025
1 parent 9028400 commit 5d713cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions fmt/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ use std::path::PathBuf;
use serde::de::Error;
use serde::Deserialize;
use serde::Deserializer;
use serde::Serialize;
use toml::Value;

use crate::default_true;

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Config {
#[serde(default = "default_cwd")]
Expand Down Expand Up @@ -57,7 +56,7 @@ pub struct Config {
pub additional_headers: Vec<String>,
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Deserialize)]
pub struct Git {
pub attrs: FeatureGate,
pub ignore: FeatureGate,
Expand All @@ -72,7 +71,7 @@ impl Default for Git {
}
}

#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum FeatureGate {
/// Determinate whether turn on the feature.
Expand Down Expand Up @@ -109,7 +108,7 @@ impl FeatureGate {
}
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Mapping {
Filename {
pattern: String,
Expand Down
6 changes: 5 additions & 1 deletion fmt/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ pub fn check_license_header<C: Callback>(
let mut mapping = config.mapping.clone();
if config.use_default_mapping {
let default_mapping = default_mapping();
mapping.extend(default_mapping);
for m in default_mapping {
if !mapping.contains(&m) {
mapping.insert(m);
}
}
}
mapping
};
Expand Down
2 changes: 1 addition & 1 deletion tests/bom_issue/licenserc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ additionalHeaders = [
"style.toml"
]

[mapping.HASH_SOURCE_STYLE]
[mapping.CS_TEST_STYLE]
extensions = ["cs"]
2 changes: 1 addition & 1 deletion tests/bom_issue/style.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[HASH_SOURCE_STYLE]
[CS_TEST_STYLE]
firstLine = "// -------------------------------------------------------"
endLine = "// -------------------------------------------------------\n"
skipLinePattern = "^#!.*$"
Expand Down

0 comments on commit 5d713cd

Please sign in to comment.