Skip to content
Pedro Mendes edited this page Aug 5, 2023 · 12 revisions

Welcome to the wiki page

Here we have usage instructions and customization documentation.

Using commit with the default pattern

The default commit pattern is an old version of angular commit message format, but you can make a custom pattern and send it to the command to override the default, see the customization section of the wiki.

In your terminal, you can just pass the command commit and the command will give you a selection of types of commits. In this case, I chose feat.

- What type of commit you will made?
> feat - A new feature
  fix - A bug fix
  docs - Documentation only changes
  style - Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  refactor - A code change that neither fixes a bug nor adds a feature
  perf - A code change that improves performance
v test - Adding missing tests or correcting existing tests
[↑↓ to move, enter to select, type to filter]

When you select a type, the command will ask you if you want to add a scope. In this case, I selected none for no scope.

- What type of commit you will made? feat - A new feature
- What scope of commit you will made? (Optional)
> custom - Custom scope
  none - No scope
[↑↓ to move, enter to select, type to filter]

In the default configuration file, there are no default scopes because it will depend on the project you are working on.

If you select custom, the program will ask you to enter the scope name, after that it will ask you to enter the commit description. In commit description, I wrote, “Now you can use commit to make patterned commits in your repo”.

- What type of commit you will made? feat - A new feature
- What scope of commit you will made? (Optional) none - No scope
- Write a SHORT, IMPERATIVE tense description of the change:

Afterward that, it will give you the option to put a message body. I just skipped this field, pressing return.

- What type of commit you will made? feat - A new feature
- What scope of commit you will made? (Optional) none - No scope
- Write a SHORT, IMPERATIVE tense description of the change: Now you can use commit to make patterned commits in your repo
- Provide a LONGER description of the change (optional):
[Commit body. Press Enter to skip]

Afterward that, the command will give you the option to put a footer message. I wrote #2 to make refer to an issue.

- What type of commit you will made? feat - A new feature
- What scope of commit you will made? (Optional) none - No scope
- Write a SHORT, IMPERATIVE tense description of the change: Now you can use commit to padronize commits in your repo
- Provide a LONGER description of the change (optional):
- List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:
[Commit footer. Press Enter to skip]

After that, the command will ask you if you want to apply the commit.

- What type of commit you will made? feat - A new feature
- What scope of commit you will made? (Optional) none - No scope
- Write a SHORT, IMPERATIVE tense description of the change: Now you can use commit to padronize commits in your repo
- Provide a LONGER description of the change (optional):
- List any ISSUES CLOSED by this change (optional). E.g.: #31, #34: #2

The commit message is:

feat: Now you can use commit to padronize commits in your repo

#2

- Do you want to apply the commit? (Y/n)

Using custom configuration file

By default, the application will check if exists a file called commit.json in the current directory (project directory) to create one, use the command commit --init in the project directory.

You can create a global configuration file called commit.json and it will be used by the application in all your projects.

~/.config/commit/commit.json (Linux)

%APPDATA%/commit/commit.json (Windows)

~/Library/Application\ Support/commit/commit.json (Mac)

commit --init

Now you can replace the default configuration fields with yours.

Fields

  • config: object: Prefix and suffix configuration and other configurations.

    Example: "config": {...} (required)

    • subject_separator: string, default ": " (required):

      This is the subject separator.

      Example: "subject_separator": "| " will be feat(scope)| this is a new feature

    • scope_prefix: string, default "(" (required): This is the commit scope prefix.

      Example: "scope_prefix": "[" will be feat[scope): this is a new feature

    • scope_suffix: string, default ")":

      This is the commit scope suffix.

      Example: "scope_suffix": "]" will be feat(scope]: this is a new feature (required)

    • type_prefix: string, default none (not required):

      This is the commit type prefix.

      Example: "type_prefix": "**" will be **feat(scope): this is a new feature

    • type_suffix: string, default none (not required):

      This is the commit type suffix.

      Example: "type_suffix": "**" will be feat**(scope): this is a new feature

    • pre_commit: string, default none (not required):

      Will run a script before the commit. The common use is to run tests before the commit or format the code.

      Note: On script execution will be passed the commit message as a environment variable called MSG.

      Example: "pre_commit": "./scripts/pre-commit.sh"

  • commit_types: array (required):

    List of commit types.

    Example: "commit_types": [{name: "feat", description: "A new feature"}]

    • name: string (required):

      Name of the commit type.

      Example: "name": "feat"

    • description: string (required):

      Description of the commit type.

      Example: "description": "A new feature"

  • commit_scopes: array (required):

    List of commit scopes.

    Example: "commit_scopes": [{name: "none", description: "No scope"}]

    • name: string (required):

      Name of the commit scope.

      Example: "name": "commit"

    • description: string (required):

      Description of the commit scope.

      Example: "description": "Commit"

    Note: The none scope and the custom scope are keywords and cannot be used as commit scope.

    The custom scope is used to create a custom commit scope, and the none scope is used to create a commit without scope.

  • skip_commit array (not required):

    List of commit fields that will be skipped.

    Example: "skip_commit": ["commit_body", "commit_footer"]

    Possible values: "commit_type", "commit_scope", "commit_description", "commit_body", "commit_footer"

  • msg object (required):

    Message configuration.

    Example: "msg": {...}

    • commit_type: string, default "What type of commit you will made?" (required):

      This is the message to ask the user to select the commit type.

      Example: "commit_type": "What type of commit you will made?"

    • commit_scope: string, default "What scope of commit you will made? (Optional)" (required):

      This is the message to ask the user to select the commit scope.

      Example: "commit_scope": "What scope of commit you will made? (Optional)"

    • commit_description: string, default "Write a SHORT, IMPERATIVE tense description of the change:" (required):

      This is the message to ask the user to write the commit description.

      Example: "commit_body": "Write a SHORT, IMPERATIVE tense description of the change:"

Clone this wiki locally