- Notifications
You must be signed in to change notification settings - Fork4
A git hook suite to supercharge your commits! Seamlessly pair program, tag issues, and craft stellar commit messages effortlessly.
License
PurpleBooth/git-mit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
git-mit is a suite of git hooks. It's aimed to make pair programming,adding issue numbers to your commits, and following good commit messagepractices something that happens without thinking about it.
This works via git hooks, so you need these hooks to be present in thegit repository you're using to use them.
git init.git mit-install
This works by creating a symlink in your repositories hooks directory.You can do this automatically by adding them to yourinittemplate. Thisis the template that git uses to create the.git
directory when yourungit init
.
git mit-install --scope=global
You can also run this on an existing repository, to set up an alreadychecked out repository. You can re-initialise all of your repositories,recursively from the home directory using this command.
find"$HOME" -type d -name .git -exec sh -c'git init "$1"/..' -- {}\;
git mit-config lint available
╭───────────────────────────────────┬──────────╮│ Lint ┆ Status │╞═══════════════════════════════════╪══════════╡│ duplicated-trailers ┆ enabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ pivotal-tracker-id-missing ┆ disabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ jira-issue-key-missing ┆ disabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ github-id-missing ┆ disabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ subject-not-separated-from-body ┆ enabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ subject-longer-than-72-characters ┆ enabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ subject-line-not-capitalized ┆ disabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ subject-line-ends-with-period ┆ disabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ body-wider-than-72-characters ┆ enabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ not-conventional-commit ┆ disabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤│ not-emoji-log ┆ disabled │╰───────────────────────────────────┴──────────╯
With only lints that ensure git will work properly enabled by default
git mit-config lint enabled
╭───────────────────────────────────┬─────────╮│ Lint ┆ Status │╞═══════════════════════════════════╪═════════╡│ duplicated-trailers ┆ enabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤│ subject-not-separated-from-body ┆ enabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤│ subject-longer-than-72-characters ┆ enabled │├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤│ body-wider-than-72-characters ┆ enabled │╰───────────────────────────────────┴─────────╯
You can read more details about this, with examples on thelintspage
You can add a.git-mit.toml
or.git-mit.toml.dist
to the root ofyour repository, and we will read it and try to enable the correct lints(with.git-mit.toml
taking precedence).
I recommend you commit.git-mit.toml.dist
and add.git-mit.toml
toyour.gitignore
to allow easy local reconfiguration
For example
[mit.lint]"pivotal-tracker-id-missing" =true
With this you can enable lints
git mit-config lint status pivotal-tracker-id-missing
╭────────────────────────────┬─────────╮│ Lint ┆ Status │╞════════════════════════════╪═════════╡│ pivotal-tracker-id-missing ┆ enabled │╰────────────────────────────┴─────────╯
You can read more about this on theconfiguringpage
In projects, it is nice to help out your co-workers by linking thecommits you're making back to the issue in the backlog. This can get abit tedious to remember though, so here's a command to reduce the amountof typing.
Say you've just made this awesomeREADME.md
for Pivotal Tracker ID[#12321513]
#The Best ReadmeThis is the best readme
If you run
git mit-relates-to"[#12321513]"
Next time you commit
git add README.mdgit mit btgit commit -m"Wrote a great README"
the commit message will contain the ID
git show --pretty='format:author: [%an %ae] signed-by: [%GS]---%B' -q
author: [Billie Thompson billie@example.com] signed-by: [] ---Wrote a great READMERelates-to: [#12321513]
Read more about this at therelates to page
Pairing is a great way to program, and it's even better when you givecredit, you can give credit with the mit command
Configure your authors like the example by creating a config at$HOME/.config/git-mit/mit.toml
git-mit-config mit example
[ae]name ="Anyone Else"email ="anyone@example.com"[bt]name ="Billie Thompson"email ="billie@example.com"signingkey ="0A46826A"[se]name ="Someone Else"email ="someone@example.com"
And you can run
git mit ae bt se
Then next when you make a commit theCo-authored-by
trailers will beset of the author initials you selected.
echo"# Hello, world!"> README.mdgit add.git commit --message="Initial Commit" --quietgit show --pretty='format:author: [%an %ae] signed-by: [%GS]---%B' -q
author: [Anyone Else anyone@example.com] signed-by: [] ---Initial CommitCo-authored-by: Billie Thompson <billie@example.com>Co-authored-by: Someone Else <someone@example.com>Relates-to: [#12321513]
Notice how the "Relates-to" tag is here even though we didn't triggerit? It's from the example higher on the page, git-mit remembers yourauthor and ticket number for 60 min
For more information on this see themit page
You can install this with brew! This is the preferred method ofinstalling.
brew install PurpleBooth/repo/git-mit
You can use Cargo too, though this won't install the completions
cargo install git-mitcargo install git-mit-configcargo install git-mit-installcargo install git-mit-relates-tocargo install mit-commit-msgcargo install mit-pre-commitcargo install mit-prepare-commit-msg
You can also download thelatestrelease and runit.
There is a script to download the latest release:
We generate completions forfish
,zsh
, andbash
. They're installedwith the homebrew package. You don't need to do anything to activatethem.
Each binary also has a command to generate completion.
About
A git hook suite to supercharge your commits! Seamlessly pair program, tag issues, and craft stellar commit messages effortlessly.