Skip to content

Proposal: Stick to Conventional Commit spec and allow extended types to be configured #51

Open
@thiagomajesk

Description

@thiagomajesk

Hi everyone!

Just included this tool as part of my workflow today and have to take my hat off to you guys, it works like a charm.

My team and I have been using Conventional Commits for some time and took the next step to also do semantic releases... However, after setting things up we discovered that the lib is not using the standard spec, but a modified/ mixed version between the Commitlint convention and then old Angular convention + and additional improvement type (which has been discussed here and here and still not agreed upon).

So, the proposal is to use the standard spec types by changing the default_types attribute to default to only feat and fix. In addition to this change, another config called extended_types should be added. This config would allow you to specify extra types to be merged into the default_types attribute, making it easier to extend values as intended by the specification:

- @default_types [
-     build: [
-       hidden?: true
-     ],
-     chore: [
-       hidden?: true
-     ],
-     ci: [
-       hidden?: true
-     ],
-     docs: [
-       hidden?: true
-     ],
-     feat: [
-       header: "Features",
-       hidden?: false
-     ],
-     fix: [
-       header: "Bug Fixes",
-       hidden?: false
-     ],
-     improvement: [
-       header: "Improvements",
-       hidden?: false
-     ],
-     perf: [
-       header: "Performance Improvements",
-       hidden?: false
-     ],
-     refactor: [
-       hidden?: true
-     ],
-     style: [
-       hidden?: true
-     ],
-     test: [
-       hidden?: true
-     ]
-   ]

+ @standard_types [
+  feat: [header: "Features", hidden?: false],
+  fix: [header: "Bug Fixes", hidden?: false]
+ ]

+ @default_types Application.compile_env(:git_opts, :types, @standard_types)

+ @extended_types Application.compile_env(:git_ops, :extended_types, [])

[...]

def types do
-    configured = Application.get_env(:git_ops, :types) || []

    @default_types
    |> Keyword.merge(@extended_types)
    |> Enum.into(%{}, fn {key, value} ->
      sanitized_key =
        key
        |> to_string()
        |> String.downcase()

      {sanitized_key, value}
    end)
  end

Another suggestion that can be part of this proposal is to add a preset option to allow users to automatically opt-in to existing conventions - like the Commitlint or Angular convention that are mentioned in the Conventional Commits website.

PS.: Another thing that I was thinking is that since most of the config types default to hidden?: false, wouldn't it be easier to invert the logic and use visible?: true, while everything else defaults to visible: false when the config is not present? On a side-note, if there are no other options other than header and hidden?, perhaps it would be better to use a tuple to configure that instead of a list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions