Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Latest commit

 

History

History
219 lines (155 loc) · 6.53 KB

README.md

File metadata and controls

219 lines (155 loc) · 6.53 KB

50-72

ℹ️ This project is archived now that GitHub formats commit messages to 72 columns automatically. While GitHub doesn't hint about over-50-column message titles, it's good enough.

50-72 is an utility to format your git commit messages to the 50/72 rule automatically:

$ git commit -m "Freestyle message
> 
> The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick
> brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."
#  |
#  |
#  |  Gets committed as
#  V
#
# Freestyle message
# 
# The quick brown fox jumps over the lazy dog. The quick brown fox jumps
# over the lazy dog. The quick brown fox jumps over the lazy dog. The
# quick brown fox jumps over the lazy dog. The quick brown fox jumps over
# the lazy dog.

📣 A browser extension for formatting merge commits on GitHub and GitLab is coming soon 📣

Installing

ℹ️ It's stable, but still pre-release. File an issue if you run into any problems

On both macOS and Linux using Homebrew:

brew install gabrielfeo/50-72/cli

Now that the 50-72 command is available, install it in a git repository:

$ 50-72 hook --install
# Or, if you write messages in Markdown:
$ 50-72 hook --install --markdown

This adds formatting to that repository's git hooks. Once installed, it'll work from command-line git as well as any Git client you use with that repo.

FAQ

Are there any other features? Can I use it in my own scripts?

A manual format command is available so you can use it as part of your own scripts (in CI, for example). Here's the full help text:

Usage: 50-72 [OPTIONS] COMMAND [ARGS]...

  Format commit messages to the 50/72 rule automatically.
  
  It's recommended to install it in the git hooks of each repository:
  
  50-72 hook --install
  
  Otherwise, manual usage is:
  
  50-72 format MESSAGE (to format a message string)
  50-72 format-file (to format the git commit message file)
  
  See --help of each subcommand for more.

Options:
-h, --help  Show this message and exit

Commands:
format       Format a message string.
format-file  Format the git commit message file (or another file)
hook         Install the 50-72 git hook in the current repository.
Are existing git hooks deleted when I run hook --install?

No. If you already have a commit-msg git hook in the repo, 50-72 hook --install simply appends to it, preserving your existing commands. If there is no commit-msg hook, it will create one.

Is it compatible with git GUIs like GitKraken, SourceTree, VS Code, IntelliJ?

It should work with any git client because they all should support git hooks. I have not tested it with every client though. If you run into any problems, please submit a new issue.

Known to work out-of-the-box:

  • VS Code
  • Let me know where else it works for you :)
Are there any messages that aren't supported?

The Issues page is the most up-to-date source to see known issues.

Are markdown messages supported?

Markdown is fully supported in the CLI and browser extension.

Do I have to re-run --install when a new 50-72 version comes out?

No. The git hook calls 50-72 itself, so it'll always get the latest installed version on your system (technically, the first one from your PATH).

How can I uninstall the hook from a repository?

From the repository root dir:

50-72 hook --uninstall
How can I uninstall command itself from my machine?

⚠️ Make sure to run 50-72 hook --uninstall in every repo before uninstalling the command itself.

brew uninstall fifty-seventy-two-cli

If you forget to uninstall the hook in some repository, you'll get a "command not found" error when you try to commit because in that repo the hook still tries to format the message using 50-72. You can remove this leftover like this, from the root dir of the repo:

sed -I bak 's/^50-72 .*//' .git/hooks/commit-msg

Building from source

If you'd like to build from source, you'll need:

  • Linux or macOS (with Xcode developer tools)
  • JDK 11 (with JAVA_HOME set)

Then just clone this repository and run from its root directory:

./gradlew :cli:buildLatestRelease

A symlink to the generated native executable will be created in cli/build/release/latest/<platform>/bin where <platform> depends on your host OS and processor architecture. Add the desired directory to your PATH variable.

Contributing

Usage and bug descriptions are great first contributions. PRs are also much welcome. Don't be afraid to ask for help.

Contributing code

Before committing, please take a look at existing commits to follow current project patterns, and of course, follow the 50/72 rule! You can install the 50-72 hook in the 50-72 repo itself.

The project is written in Kotlin Multiplatform compiling to native code (for the CLI) and JavaScript (for the browser extension). The build system is Gradle.

  • To run all tests, ./gradlew check. Report is generated in build/reports/ of each project.
  • To build a CLI binary, see the "Building from source" section.
  • To build the CLI with debug symbols, ./gradlew :cli:linkDebugExecutable. Outputs to cli/build/bin/.
  • To build the browser extension, ./gradlew :browser-extension:assemble. Outputs to browser-extension/distributions/. Load it unpacked in Chrome to test it.