Everduin94 / better-commits

A CLI for creating better commits following the conventional commits specification
MIT License
1.88k stars 69 forks source link

How to remove Select optional footers list whilst keeping the default selected #80

Closed krupis closed 5 months ago

krupis commented 5 months ago

Hello. I am using the following .better-commits.json config:

{
    "check_status": true,
    "commit_type": {
        "enable": true,
        "initial_value": "feat",
        "infer_type_from_branch": true,
        "append_emoji_to_label": false,
        "append_emoji_to_commit": false,
        "options": [
            {
                "value": "feat",
                "label": "feat",
                "hint": "A new feature",
                "emoji": "✨",
                "trailer": "Changelog: feature"
            },
            {
                "value": "fix",
                "label": "fix",
                "hint": "A bug fix",
                "emoji": "🐛",
                "trailer": "Changelog: fixed"
            },
            {
                "value": "docs",
                "label": "docs",
                "hint": "Documentation only changes",
                "emoji": "📚",
                "trailer": "Changelog: documentation"
            },
            {
                "value": "test",
                "label": "test",
                "hint": "Adding missing tests or correcting existing tests",
                "emoji": "🚨",
                "trailer": "Changelog: test"
            },
            {
                "value": "ci",
                "label": "ci",
                "hint": "Changes to our CI configuration files and scripts",
                "emoji": "🤖",
                "trailer": "Changelog: ci"
            },
            {
                "value": "",
                "label": "none"
            }
        ]
    },
    "commit_scope": {
        "enable": false,
        "custom_scope": false,
        "initial_value": "app",
        "options": [
            {
                "value": "app",
                "label": "app"
            }
        ]
    },
    "check_ticket": {
        "infer_ticket": true,
        "confirm_ticket": true,
        "add_to_title": true,
        "append_hashtag": false,
        "title_position": "start"
    },
    "commit_title": {
        "max_size": 70
    },
    "commit_body": {
        "enable": false,
        "required": false
    },
    "commit_footer": {
        "enable": true,
        "initial_value": ["trailer"]
    },
    "breaking_change": {
        "add_exclamation_to_title": true
    },
    "confirm_commit": true,
    "print_commit_output": true,
    "branch_pre_commands": [],
    "branch_post_commands": [],
    "worktree_pre_commands": [],
    "worktree_post_commands": [],
    "branch_user": {
        "enable": true,
        "required": false,
        "separator": "/"
    },
    "branch_type": {
        "enable": true,
        "separator": "/"
    },
    "branch_ticket": {
        "enable": true,
        "required": false,
        "separator": "-"
    },
    "branch_description": {
        "max_length": 70
    },
    "branch_action_default": "branch",
    "enable_worktrees": true,
    "overrides": {}
}

As you can see from above, in my commit_footer, I only have the initial value left out:

    "commit_footer": {
        "enable": true,
         "initial_value": ["trailer"]
    },

I am trying to simplify the commit process and we do not really need to select from the below list: image

Since I only left the "initial_value": ["trailer"] I was hoping that I will no longer need to select out of the other optional footers (closes, breaking change, deprecated, custom list and it will automatically select a trailer option for me but that is not the case.

I would very much appreciate if someone could clarify how can I remove this select list when I am performing commit whilst always appending trailers based on commit types.

krupis commented 5 months ago

I have figured it out. if I set the commit_footer enable flag to false :

    "commit_footer": {
        "enable": false,
        "initial_value": ["trailer"],
        "options": [
            "trailer"
        ]
    },

Then it will no longer ask me to select commit_footer options out of the list but it will still append the trailer which is exactly what I need! :)