Skip to content

A linter to improve Git commit messages. It checks for title length, title type capitalization, dot at the end of the title, and description length of the last git commit message. It also opens an editor to write a commit message with an inline explanation of a good commit message.

License

Notifications You must be signed in to change notification settings

dipbazz/pretty_commit

Repository files navigation

Pretty commit

Table of contents


About

This project helps to check git commit message if we followed the well-adapted commit guidelines or not.

The screenshot after running cmd ./bin/main.rb and linter showing errors.

Screenshot of code in action

Definition

Why to follow git commit guidelines?

Git commits message is a way to tell other developers what you have accomplished in the current commit of your code so that they will understand what has been changed or updated in the codebase. Because of that, we should follow the commit guidelines that can save us and other developers time to figure out why certain changes were adopted.

Commit structure to follow

<type> [<scope>(optional)] <short_summary>

<description>
  • <type> can be from a list ["build", "ci", "docs", "feat", "add", "update", "refactor", "fix", "style", "test", "revert", "perf"]
  • <scope> is optional but could be anything specifying the place of changes filename, location, functions, etc.
  • <short_summary> short explanation in imperative mood. Not capitalized. No period in the end.
  • <description> This is the part where you leave a detailed description of your changes during commit. Try to explain what and why you have done something. But be sure to wrap every line within 72 characters.

Good commit message

Summarize changes in around 50 characters or less

More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.

Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.

Further paragraphs come after blank lines.

 - Bullet points are okay, too

 - Typically a hyphen or asterisk is used for the bullet, preceded
   by a single space, with blank lines in between, but conventions
   vary here

If you use an issue tracker, put references to them at the bottom,
like this:

Resolves: #123
See also: #456, #789

For more information regarding how you can have a great commit message, you can follow Chris Beams article about How to Write a Git Commit Message

Bad commit messages

The commit message which only has a title trying to explain everything in one line and exceeds the line limit of 50 chars or more
commit title that ends with a dot.
Test FileHandler to accept only .pdf file

The title is good but possibly a description is not wrapping within a 72 characters line limit is another example of a bad commit message.

Built With

  • Ruby

Getting Started

  • Clone this repo.
  • Navigate to the preety_commit directory
  • install the gem package with bundle install
  • you have it now at your local machine. For usage see usage

To test the code with rspec.

  • install rspec using gem install rspec
  • run rspec or rspec --format doc on your terminal to test the code.

Usage

In your terminal by running ./bin/main.rb -h you can get all the usage.

Usage: ./bin/main.rb [-p <dir_path>] [-c] [-h]

Explanation of arguments:
 -p      is to specify a path for a directory.
 -c      is to specify if you want this program to run git commit for you.
 -h      gives you this help mesage.

<dir_path> can be:
   1. /path/to/your/project/directory/
   2. . (default)

Authors

👤 Dipesh Bajgain

🤝 Contributing

Contributions, issues, and feature requests are welcome!

Show your support

Give a ⭐️ if you like this project!

Acknowledgments

📝 License

This project is MIT licensed.

About

A linter to improve Git commit messages. It checks for title length, title type capitalization, dot at the end of the title, and description length of the last git commit message. It also opens an editor to write a commit message with an inline explanation of a good commit message.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages