m1foley / fit-commit Goto Github PK
View Code? Open in Web Editor NEWA Git hook to validate your commit messages based on community standards.
License: MIT License
A Git hook to validate your commit messages based on community standards.
License: MIT License
This .pre_commit.yml
should work:
---
Validators/LineLength:
SummaryWarnLength: 72
That currently leads to an error because it expects Enabled
to be specified again. Config properties should be merged more intelligently.
def self.run
runner.run || exit(1)
end
either runner.run should return the exit code or it should be more clear here why a falsy return is an error.
I'm happy to make a PR to change it, if you'd like.
Hi,
ValidatorLoader#all_validators
is only loading the files in the validators directory.
It would be great to have another directory to be able to define custom validators.
Message must use present imperative tense.
Imperative describes a verb's mood, not its tense (present is its tense). However, I propose that what you're referring to is actually a bare infinitive (both have the same form, different functions). The commit message is not commanding someone to make a change—it serves as a description of the change already made—so I propose that something like "Fix bug #1111" is a noun phrase headed by an infinitive rather than being a finite clause.
Thoughts?
Proposed language:
Message must use an infinitive.
It seems sir, that we had a very similar idea at a very similar time. I've had this in mind for a while, but started working on gitlint last week: https://github.com/jorisroovers/gitlint.
Still very early stages like fit-commit, but I think we can probably learn from one another and share some ideas/code :)
Hi,
Thanks for your work on making this tool easy to install and use. A colleague and I are planning on using it within our workflow for an upcoming project.
We are running into something really strange -- When I use a bad commit message I see what the Example shows in the readme. Errors and the ability to respond with y/n/e.
But when my colleague attempts to do the same thing - he gets warnings instead and no prompt with y/n/e. And the commit successfully goes through.
Do you have any ideas on what this could be? We are not using a custom config. We've compared versions and they are the same. We've tried uninstalling and reinstalling. We just can't figure out why I am seeing errors and he is seeing warnings.
Thanks!
When you use commit -v
it displays the diff in an editor in the format
[commit area]
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
# Changes to be committed:
# modified: src/someeeeeeeeeeeeeeeeeee/long/__tests__/file-name.ts
#
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git a/src/someeeeeeeeeeeeeeeeeee/long/__tests__/file-name.ts b/src/someeeeeeeeeeeeeeeeeee/long/__tests__/file-name.ts
index de6616d..773896f 100644
--- a/src/someeeeeeeeeeeeeeeeeee/long/__tests__/file-name.ts
+++ b/src/someeeeeeeeeeeeeeeeeee/long/__tests__/file-name.ts
@@ -6,7 +6,7 @@ import {User} from "../../../services/users"
import {Blah} from "../../../types/blah"
const x: Blah = {
- id: "id",
+ id: "something",
}
fit-commit does not ignore lines below the # Everything below it will be ignored.
line
Hello Mike,
I finally managed to publish the npm package.
Here the link: https://www.npmjs.com/package/fit-commit-js
Greetings
Daniela
Whenever I do a commit, I get the following warning:
$ git commit -m 'test'
Warning! PATH is not properly set up, '/Users/$USER/.rvm/gems/ruby-2.2.3/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.2.3'.
My path is set up correctly, with the above line appearing first. However, if I echo $PATH
from inside the .git/hooks/commit-msg file, i get:
/usr/local/Cellar/git/2.5.0/libexec/git-core:/usr/local/Cellar/git/2.5.0/libexec/git-core:/Users/$USER/.rvm/gems/ruby-2.2.3/bin...
Digging into this a little more, i found someone else had a very similar issue: rvm/rvm#2347
The suggested solution is to use ruby-rvm-env
instead of rvm default do ruby
as the command. I changed my local commit-msg hook, and it worked! No warning (yey).
If you like, I can submit a pull request to change this in the template.
We currently disallow WIPs, etc. to master
, but what we really mean is a "business" or "public" branch where you're interacting with other people. Not all workflows use master
as this branch (e.g., the git-flow process) so it needs to be customizable.
When looking at my git history I get things like:
commit 5e554e17435254f20aa8e1098bd5049726f707fb
Merge: 04d3c52 b200694
Author: Fabien Penso <XXX>
Date: Tue Aug 24 06:15:05 2021 -0400
Merge branch 'master' into fabien/be-1556-some-beam-objects-are-not-synced
because our branch names are long (based on linear which likes to create its own branch names). This is failing fit-commit, I think it should skip validation on any merge commits.
Developers hate being told to do without justification. Every rule has reasoning behind it, but it is not always obvious.
If you make (or amend) any commits during an interactive rebase, you receive the following warning:
fatal: ref HEAD is not a symbolic ref
fit-commit: WARNING: Skipping checks because the Git branch cannot be determined.
Steps to reproduce:
git rebase -i HEAD~1
pick
to edit
for the commit showngit commit --amend
(no need to change anything)It doesn't seem to cause any negative side-effects, aside from not actually catching any invalid commit messages.
fit-commit uninstall
should simply remove .git/hooks/commit-msg
.
I do my commits in my preferred $EDITOR. When exiting $EDITOR to commit and fit-commit finds an issue I am forced to retype my commit and try the commit again.
My propsed solution would have an option along the lines of
Force commit? [y/n/e]
With e for edit dropping you back into $EDITOR with the incorrect message to make the changes needed.
I am not no handy in ruby or I would hack away at it myself.
fit-commit throws an error on the first commit in a repository: "Could not get sha1 for HEAD. Skipping."
Fit Commit was written with the assumption that feature branches are treated with more leniency than the "shared branches" (master
by default). I think this distinction isn't very helpful because people have different workflows, and it's not a big deal to press y
to approve lazy messages on non-shared branches.
Hi, this is an awesome project! Thank you for creating it.
It would be very nice if it also had validation against commit messages not starting with a capital letter though. In my experience, it is usually the thing that is the most inconsistent in other people's commit messages.
It is even recommend as one of the seven rules in the post you linked to: http://chris.beams.io/posts/git-commit/#capitalize
Nice work @m1foley
I've noticed something strange when running under MINGW32.
From the prompt if I commit using git commit -m "Fixes Something"
and hit enter I get what appears to be a hang. It's not until I hit enter for a second time I see the results of fit-commit.
Here's a screen after hitting enter
Here's a screen after hitting enter for a second time.
Is there something prompting for a console input?
e.g., brogrammers will want to disable Frat House validation.
I've installed fit-commit and tried to commit:
/Users/damirsvrtan/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/fit-commit-1.0.1/lib/fit-commit/runner.rb:72:in `initialize': No such file or directory @ rb_sysopen - (Errno::ENOENT)
from /Users/damirsvrtan/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/fit-commit-1.0.1/lib/fit-commit/runner.rb:72:in `open'
from /Users/damirsvrtan/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/fit-commit-1.0.1/lib/fit-commit/runner.rb:72:in `message_text'
from /Users/damirsvrtan/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/fit-commit-1.0.1/lib/fit-commit/runner.rb:68:in `relevant_message_lines'
from /Users/damirsvrtan/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/fit-commit-1.0.1/lib/fit-commit/runner.rb:64:in `lines'
from /Users/damirsvrtan/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/fit-commit-1.0.1/lib/fit-commit/runner.rb:80:in `empty_commit?'
from /Users/damirsvrtan/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/fit-commit-1.0.1/lib/fit-commit/runner.rb:17:in `run'
from /Users/damirsvrtan/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/fit-commit-1.0.1/lib/fit-commit.rb:5:in `run'
from -e:11:in `<main>'
It's great having client-side validation, but let's face it some developers will simply forget or be too lazy to set it up, and then they'll submit bad commits for review regardless. So ideally there should be a way to enforce validation server-side. Of course the implementation depends on the server in question, but GitHub might be a good place to start. For example might it be possible to create a GitHub third-party service which runs fit-commit server-side whenever a PR is submitted / updated, and then updates a status check on the PR accordingly?
See also codeclimate/spec#45 (allow analysis of commit messages)
Is there any plan on providing it on homebrew or should Mac users just use gem?
Using RubyMine, I get the following error when attempting to commit:
Error:.git/hooks/commit-msg: line 38: /dev/tty: Device not configured
This is the same issue as described here:
http://stackoverflow.com/questions/17930805/github-gui-client-dev-tty-device-not-configured
And so it looks like it affects more than just Rubymine.
It would be nice if there was a non-interactive option, either auto-failing or auto-forcing with a warning in the face of an error, that did not make use of /dev/tty.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.