Skip to content
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

Ignoring case in serde deserialization for config types #219

Open
danyal002 opened this issue Apr 12, 2024 · 3 comments
Open

Ignoring case in serde deserialization for config types #219

danyal002 opened this issue Apr 12, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@danyal002
Copy link

danyal002 commented Apr 12, 2024

Is your feature request related to a problem? Please describe.

One of the frustrations I have whilst using Convco is that if any of my merge commits suffixes use title case like "Feat" or "Fix" instead of "feat" and "fix", my entire workflow stops. I'd like Convco to ignore the case of the type. This is currently done in the deserialize_type method in /src/conventional/config.rs. Conventional commits does allow for "any casing to be used".

Describe the solution you'd like

We convert the r#type to lower case and then match in the deserialize_type method.

@danyal002 danyal002 added the enhancement New feature or request label Apr 12, 2024
@hdevalke
Copy link
Collaborator

You probably are referring to this: https://github.com/convco/convco/blob/main/src/conventional/config.rs#L131?

I think the workaround would be to add in your config that Feat increments Minor and Fix increments Patch. I would have to check if there are other places to fix.

@danyal002
Copy link
Author

danyal002 commented Apr 12, 2024

Yes, I am indeed referring to that (https://github.com/convco/convco/blob/main/src/conventional/config.rs#L131).

It feels like a heavyweight thing to do to just work around a case sensitivity issue. It also doesn't fully solve the issue, e.g. if there's a typo like "feAt" or "fiX" or any other variation, we'd need a case for that too.

My suggested changes would be as follows:

Change

till line 139 to:

.map(
                |PartialType {
                    r#type,
                    increment,
                    section,
                    hidden,
                }| {
                    let r#type = r#type.to_ascii_lowercase();
                    Type {
                        r#type: r#type.clone(),
                        increment: increment.unwrap_or(match r#type.as_str() {
                            "feat" => Increment::Minor,
                            "fix" => Increment::Patch,
                            _ => Increment::None,
                        }),
                        section,
                        hidden,
                    }
                },
            )

and change

let r#type = capts.name("type").map(|t| t.as_str().to_owned());
to:

let r#type = capts.name("type").map(|t| http://t.as_str().to_ascii_lowercase());

What do you think?

@hdevalke
Copy link
Collaborator

I think it is good that convco check does check the case as it makes the commit messages consistent.

Do you only have issues with merge commits (commit with more than 1 parent)? There is an option to ignore merge commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants