Giter Club home page Giter Club logo

better-commits's Introduction

Hello There ๐Ÿ‘‹

  • ๐Ÿ”ญ Iโ€™m currently working on
  • ๐ŸŒณ I used to work on
    • Utility GIS Applications
    • Angular articles Medium
  • ๐ŸŒฑ Iโ€™m currently learning: Svelte, Postgres, ZOD
  • ๐Ÿ“ซ How to contact me: Socials at the bottom
  • โšก Fun fact: I am a black belt in Brazilian Jiu Jitsu

Setup

neovim arch alacritty

home-3

Projects

flotes-g-2

Svelte Supabase tw vercel

Web Application / PWA - Markdown Notetaking with Flashcard Features

2023-08-11_13-27

bc-gradient

Typescript ZOD

A CLI for writing better commits, following the conventional commit guidelines

Screen.Recording.2023-03-14.at.12.27.22.PM.mov

blog

astro tw md

image

Socials

youtube discord linkedin

better-commits's People

Contributors

alexhodson avatar bhanudatsinhjhala avatar everduin94 avatar exdeniz avatar j-grosse avatar mike-minchenko avatar penleychan avatar ravvi-kumar avatar semantic-release-bot avatar sonyarianto avatar vitorlostadac avatar woofenator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

better-commits's Issues

CI and Semantic Release

Currently, better-commits process for deploying looks like this:

  • manually bump version number in package.json
  • manually build via npm run build
  • manually publish via npm publish

Utilizing Github Actions + Semantic Release, we could automate this process. Which would make accepting other user's PRs simpler.

This would be a good first time issue / help wanted -- as I won't be able to get to this for a while

Default "max_items" value set to null

Just tried to install on a new machine and when I first run the "better-commits" command. The following response was given:

Found global config
โ”‚
โ–  Invalid Configuration: commit_type.max_items
โ”‚ Invalid type: Expected number but received null

I've had a look into the base global configuration file and for both commit_type.max_items & commit_scope.max_items are both set to null by default. Tried inputting the default configuration provided in the README, but the compains about "Infinity". Only way I can resolve this is to hardcode the max_items property to a specific number.

Question: Ticket initial value on cli for ticket with numbers and characters

We are using clickup and our branch name are structured as:
CU-863gvp799_Run-tests-only-if-not-PR-in-draft

When moving through the flow it wont pre-populate the ticket correctly and seems to cut off after the last number:

image

If there is no configuration that will cover this, I am happy to contribute.

My 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": "hotfix",
                "label": "hotfix",
                "hint": "Hotfixing any critical bug",
                "emoji": "๐Ÿšจ"
            },
            {
                "value": "feat",
                "label": "feat",
                "hint": "A new feature",
                "emoji": "โœจ"
            },
            {
                "value": "fix",
                "label": "fix",
                "hint": "A bug fix",
                "emoji": "๐Ÿ›"
            },
            {
                "value": "docs",
                "label": "docs",
                "hint": "Documentation only changes",
                "emoji": "๐Ÿ“š"
            },
            {
                "value": "refactor",
                "label": "refactor",
                "hint": "A code change that neither fixes a bug nor adds a feature",
                "emoji": "๐Ÿ”จ"
            },
            {
                "value": "perf",
                "label": "perf",
                "hint": "A code change that improves performance",
                "emoji": "๐Ÿš€"
            },
            {
                "value": "test",
                "label": "test",
                "hint": "Adding missing tests or correcting existing tests",
                "emoji": "๐Ÿšจ"
            },
            {
                "value": "build",
                "label": "build",
                "hint": "Changes that affect the build system or external dependencies",
                "emoji": "๐Ÿšง"
            },
            {
                "value": "ci",
                "label": "ci",
                "hint": "Changes to our CI configuration files and scripts",
                "emoji": "๐Ÿค–"
            },
            {
                "value": "chore",
                "label": "chore",
                "hint": "Other changes that do not modify src or test files",
                "emoji": "๐Ÿงน"
            },
            {
                "value": "",
                "label": "none"
            }
        ]
    },
    "commit_scope": {
        "enable": true,
        "custom_scope": false,
        "initial_value": "app",
        "options": [
            {
                "value": "app",
                "label": "app"
            },
            {
                "value": "config",
                "label": "config"
            },
            {
                "value": "tools",
                "label": "tools"
            },
            {
                "value": "infrastructure",
                "label": "infrastructure"
            },
            {
                "value": "",
                "label": "none"
            }
        ]
    },
    "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": true,
        "required": false
    },
    "commit_footer": {
        "enable": true,
        "initial_value": [],
        "options": [
            "deprecated",
            "closes",
            "breaking-change",
            "custom"
        ]
    },
    "breaking_change": {
        "add_exclamation_to_title": true
    },
    "confirm_commit": true,
    "print_commit_output": true,
    "branch_pre_commands": [],
    "branch_post_commands": [],
    "branch_user": {
        "enable": false,
        "required": false,
        "separator": "/"
    },
    "branch_type": {
        "enable": false,
        "separator": "/"
    },
    "branch_ticket": {
        "enable": true,
        "required": false,
        "separator": "_"
    },
    "branch_description": {
        "max_length": 70
    }
}

How to use better-commits package locally within repository

Hello. I have been using globally installed better-commits (using npm install -g better-commits) and everything was fine.

Since we have many people on the team working on the same project (repository), I would like to install the better-commits package locally to the repository and upload the node_modules and package.json to git to ensure that all team members can just simply use the package out of the box

I cd into my repository and installed the better-commits locally using npm install better-commits and uninstalled the global package using npm uninstall -g better-commits. After that, I uploaded all the generated node files to the git.

After I uninstalled the better-commits globally, I have tried to use the locally installed better-commits but that does not seem to work even though the npm list says that I have the package installed:

image

Could someone clarify to me what could be an issue and how to correctly use locally installed package?

My guess is that when I run better-commits it is looking for node_modules in the local directory which is:
C:\Users\petrikas.lu\AppData\Roaming\npm\node_modules

However, node_modules exist in the project directory

Issue did not close

Hey, thanks for making this! It looks really cool.

I just started playing around with it and noticed that my issue did not close. Can you maybe tell what went wrong?

T   better-commits
|
o  Found repository config
|
o   Checking Git Status
|
*  Changes to be committed:
|  .better-commits.json
|
o  Select a commit type
|  fix
|
o  Select a commit scope
|  yo momma
|
o  Ticket / issue infered from branch (confirm / edit)
|  1
|
o  Write a brief title describing the commit
|  Calculate weight of yo momma
|
o  Write a detailed description of the changes (optional)
|  So far it has not been possible to compute the weight of your mom but now we know she is so fat.
|
o  Select optional footers (<space> to select)
|  closes <issue/ticket>, breaking change
|
o  Breaking changes: Write a short title / summary
|  Yo momma breaks everything she sits on
|
o  Breaking Changes: Write a description & migration instructions (optional)
|  Breaks chairs, sofas, and so on
|
o  Commit Preview -----------------------------------------------------------------------------------+
|                                                                                                    |
|  fix(yo-momma)!: 1 Calculate weight of yo momma                                                    |
|                                                                                                    |
|  So far it has not been possible to compute the weight of your mom but now we know she is so fat.  |
|                                                                                                    |
|  BREAKING CHANGE: Yo momma breaks everything she sits on                                           |
|                                                                                                    |
|  Breaks chairs, sofas, and so on                                                                   |
|                                                                                                    |
|  Closes: 1                                                                                         |
|                                                                                                    |
+----------------------------------------------------------------------------------------------------+
|
o  Confirm Commit?
|  Yes

I then merged the branch (fix/1-yo-momma-so-fat) via a merge commit: grandeljay/better-commits-test@643c432 but the issue did not close or was mentioned/linked in any way.

What did I do wrong?

License

Hi, please add license to project :)

Support to emojis

Hi,

Would be nice to have support to emojis, the same way commitzen uses [emoji-cz)[https://github.com/kevin940726/emoji-cz].
Amazing job with better-commits. Thanks!

Kind regards
Vitor Jr.

Title Template Property

Context

Based on #69

Today, although each property is optional, the order in the title is fixed to match conventional commits.

TYPE(SCOPE): TICKET DESCRIPTION

Tasks

Create a property title_template

  • Default: type(scope): ticket description

Zod Validation

  • Enforce key words: ["type", "scope", "ticket", "description"]
  • Enforce separators: ["/", "-", "_", "[]", "()", ":", "{}"]

Regex

  • Update string builder to use template

Concerns

  • More difficult to enforce things like "if () is empty remove, if no text before colon then remove colon" etc...

Outstanding Tasks

  • This will effectively make fields like optional or separator redundant in some cases. Should we deprecate?
  • We may want to add some way to add custom fields / prompts

Config Explanation Table (Readme)

A table should be added to the Readme that explains what each property does

This would be a good first time issue / help wanted

I can fill in any gaps or help with any explanations if someone else ends up picking this up

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

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.

Reduce Size: Remove SimpleGit

SimpleGit makes up about 38% of the projects size.

But, better-commits only uses git status from SimpleGit. Which coincidentally creates one of the few known issue in better-commits. (Files that have both staged and unstaged changes only show up as staged)

Action Items

  • Create a replacement for git status
  • Remove SimpleGit

append_hashtag option does not work when ticket cannot be inferred

When I have a branch without a ticket that can be inferred, eg my-feature-branch, but specify the ticket manually, the hash is not added to the ticket. Example:

.better-commits.json (partial)

	"check_ticket": {
		"infer_ticket": true,
		"confirm_ticket": true,
		"add_to_title": true,
		"append_hashtag": true,
		"surround": "",
		"title_position": "start"
	},

output (branch my-branch):

โ”Œ   better-commits 
โ”‚
โ—‡  Found repository config
โ”‚
โ—‡   Checking Git Status 
โ”‚
โ—†  Changes to be committed:
โ”‚  styles.css
โ”‚
โ—‡  Select a commit type
โ”‚  โœจ feat
โ”‚
โ—‡  Add ticket / issue (optional)
โ”‚  5
โ”‚
โ—‡  Write a brief title describing the commit
โ”‚  abc
โ”‚
โ—‡  Write a detailed description of the changes (optional)
โ”‚  123
โ”‚
โ—‡  Select optional footers (<space> to select)
โ”‚  closes <issue/ticket>
โ”‚
โ—‡  Commit Preview โ”€โ•ฎ
โ”‚                  โ”‚
โ”‚  โœจ feat: 5 abc   โ”‚
โ”‚                  โ”‚
โ”‚  123             โ”‚
โ”‚                  โ”‚
โ”‚  Closes: 5       โ”‚
โ”‚                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ”‚
โ—‡  Confirm Commit?
โ”‚  No
โ”‚
โ—  Exiting without commit

infer type from branch

To support a future feature "better-branch", a CLI for following branch naming conventions. We want to be able to infer the type from the branch name.

Example + Video

Create an example commit that uses most of better-commits features.

Add a video to the readme demonstrating this commit.

Detailed description is not commited

I've noticed this a couple times while writing a detailed description of the commit. It simply won't show when I look at the commit on GitHub or similar.

Can you reproduce this behaviour?

Feature Request: homebrew formula

Create a homebrew formula for better-commits so that it can be installed globally with something like brew install better-commits on macOS and Linux.

Could either be a custom tap or included in homebrew/core.

Renaming file without changes results in "no changes to commit"

โฏ git status
On branch feat/productpage
Your branch is up to date with 'origin/feat/productpage'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        renamed:    content/en/products.md -> content/en/pricing.md

[15:04:11][patrick@Behemoth]~/gitlab.com/wonderland/wonderland-engine-website(+1|%0|ok)
โฏ 

followed by better-commit:

โ”Œ   better-commits 
โ”‚
โ—‡  Found global config
โ”‚
โ—‡   Checking Git Status 
โ”‚
โ—†  Changes to be committed:
โ”‚  
โ”‚
โ–   no changes added to commit (use "git add" and/or "git commit -a")

Add description to commit types

How about adding a simple description next to commit types, such as the Angular convention:

image

And simply adding those here
image

I always struggle to choose the right one and end up opening my browser to find which is for what

Branch Template Property

Context

Based on #68 (@groovyghoul)

Today, although each part is optional, the order in the branch name when running better-branch is fixed.

USER/TYPE/TICKET-DESCRIPTION

Tasks

Create a property branch_template

  • Default: user/type/ticket-description

Zod Validation

  • Enforce key words: ["user", "type", "ticket", "description", "version"]
  • Enforce separators: ["/", "-", "_"]

Regex

  • Update builder to use template
  • See #70 make sure to not break inference between these two changes

Add either

  • A way to make custom fields / prompts
  • Optional version number field (leaning towards this for now)

Outstanding Tasks

  • This will effectively make fields like optional or separator redundant in some cases. Should we deprecate?

Missing description body

The description body still show when I'm using better-commit in cli.
But it disappeared after commit. It also disappeared in github UI. Just show only short description

image

Issue: Something went wrong when committing: Error: spawnSync /bin/sh ENOENT

image

I have the following error: Something went wrong when committing: Error: spawnSync /bin/sh ENOENT.
I'm using Git Bash on a Windows 11 machine. Initiated the prompt with npx better-commits.
Is there something I could do to fix this issue?

This error looks like a cwd error with bin/sh but when I use the command /bin/sh -c ls bash could find the sh executable.

SystemError

Hi there,

I am getting the following error, I did see this in the troubleshooting section, I wouldn't be hurt if you close this issue directly:

image

Steps to reproduce:

  • npm install -g better-commits.
  • go to folder which has an existing repository, open git bash.
  • type: better-commits

Using:

  • Windows 10
  • NVM
  • Node 19.8.1
  • Git bash (seems to be the problem, powershell does work).

Better-branch

Hi, if you're reading this, then I'd like your input ๐Ÿ˜…

A new feature I'm planning would be an additional prompt / cli for generating a branch following a common convention

Some features

  • infer user name
  • prompt feature
  • prompt ticket / issue
  • prompt title
  • run pre-checkout scripts
  • run post-checkout scripts

It would generate a branch name like this:

everduin94/feat/28-better-branches

And run any scripts like npm install, git pull, etc...

Does this feature make sense? Anything that should be added or considered? Does this seem useful to your workflow?

Request for Feature to Customize Ticket Format in Commit Messages

Hello,

I'm a developer working with a team where we follow a specific commit message convention: type(scope): [jira_id] Commit_title. We are interested in using the better-commits tool to streamline our development process. However, we have encountered an issue that better-commits does not seem to support customizing the ticket format in the check_ticket configuration, particularly adding brackets around the ticket ID.

Our team's convention requires the JIRA ticket ID to be enclosed in square brackets ([jira_id]), which is a crucial part of our workflow. Currently, the better-commits tool allows adding a ticket to the title but does not support this specific format.

I would like to inquire if there is any consideration for introducing a feature that allows customizing the ticket format, particularly for adding brackets around the ticket ID. If there's an interest in supporting this feature, I would be very eager to contribute to the project, ideally starting in early February.

Thank you for your time and consideration, and I look forward to any guidance or suggestions you may have on this matter.

Title count

Not sure if this is possible, but when typing the title for the commit, a count of how many characters are left before hitting the max length would be helpful.

Reduce Size: Replace Zod with Valibot

Zod makes up 30% of the size of better-commits. Zod is crucial to better-commits, so it shouldn't simply be removed. But, better-commits is a very small project and uses a minimal amount of the Zod API.

Thus, replacing Zod with Valibot seems like a pretty good choice for a project of this size.

Action Items

  • Replace Zod with Valibot
  • Replace Zod-Validation-Error
  • Remove Zod

Caveat: Better-commits makes use of advanced utilities like refine and transform. See this documentation for replacements. Namely, custom and transform

Caveat: Unsure of effort needed to replace Zod-Validation-Error

How to add commit trailer based on commit type selected

Hello. I use Gitlab built-in feature (glab) to generate Changelogs for my projects based on Commit trailer messages as described here:
https://docs.gitlab.com/ee/user/project/changelogs.html

In order for glab to detect commits, each commit needs to have a commit trailer. My commit example:

git commit -m "fixed voltage measurement issue" --trailer "Changelog: fixed"

The following commit with a trailer will then show up in the Gitlab as shown below:
image

And when I generate the changelog, it will look something like:

## 1.0.2-5-g796eb48
 (2024-01-25)

### fixed (1 change)

- [fixed voltage measurement issue](testing/universal-testboard-v3@825b7b5474216ab7abc84af033b417a766952e8e) ([merge request](testing/universal-testboard-v3!1))

Since I am making all commit messages and commit trailers by hand, this method is very sensitive to human error. For example if I make typo when writing a commit trailer, the glab will not detect the commits.

I was hoping to use better-commits to automate this process and ensure each commit is tagged with appropriate commit trailer based on selected commit type.

For example, I have a list of commit types:

    "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": "โœจ"
            },
            {
                "value": "fix",
                "label": "fix",
                "hint": "A bug fix",
                "emoji": "๐Ÿ›"
            },
            {
                "value": "docs",
                "label": "docs",
                "hint": "Documentation only changes",
                "emoji": "๐Ÿ“š"
            },
            {
                "value": "test",
                "label": "test",
                "hint": "Adding missing tests or correcting existing tests",
                "emoji": "๐Ÿšจ"
            },
            {
                "value": "ci",
                "label": "ci",
                "hint": "Changes to our CI configuration files and scripts",
                "emoji": "๐Ÿค–"
            },
            {
                "value": "",
                "label": "none"
            }
        ]
    },

Is there a possibility to append a trailer to commit message based on selected commit type? For example, if I select feat , I want to automatically append Changelog: added as my Commit trailer.

If I select fix, I want to append Changelog: fixed and etc...

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.