New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: initial release #6
Conversation
For intensive git operations, it can be problematic to have every git hook trigger every time - this leads to a substantial reduction in performance. We should instead recommend just listing a subset of hooks to include in the husky config file.
module.exports = require('@mixmaxhq/git-hooks'); | ||
|
||
// Husky explicitly greps for the hook itself to determine whether to run the hook. Here are the | ||
// hooks, to bypass this check: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it was a ton of work!
I'm curious if we even really have any recourse for the divergent-history case that you have TODO'd. I'm not sure how we could make this smart enough to have a useful behavior there.
Also, some of this tooling pipeline is a bit over my head, but the hooks themselves read fine to me. I'd be willing to be a beta tester for these!
It took me all morning! I can absolutely fix the divergent-history case, but I feel like I should add unit tests before I do so. We can make it smart by just linting the commits that are on the local branch but not on the remote branch.
I think that's probably exactly how this'll work! Unfortunately, we still need to install them in all the repositories, but I'll publish it and you're encouraged to take it for a spin in your next project - just follow the readme :) |
src/bin/hook-commands/pre-push.js
Outdated
switch (mode) { | ||
case 'unpushed': { | ||
const [localBranch, remoteBranch] = await Promise.all([ | ||
git('branch', '--show-current'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this flag new? i see it in the latest git docs but i've never seen it before nor does it work when i run it locally:
> git branch --show-current
error: unknown option `show-current'
i'm on git version 2.20.1 btw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was added in 2.22.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add some sort of safeguard for this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotta love developing for macs :s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, outside of a few missing awaits.
Co-Authored-By: Shil Sinha <shil.sinha@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm sans the git versioning thing
7961ab6
to
0a8eecc
Compare
🎉 This PR is included in version 1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Introduces a couple of useful git hooks:
commit-msg
, which checks that commit messages authored bygit commit
orgit commit --amend
comply withcommitlint
pre-push
, which checks (depending on the configuredmode
) whether all commits or just the unpushed commits on the branch passcommitlint
These are configured in
~/.config/mixmax/config
:It'd be real neat to be able to have a more self-contained
git-hooks
module, but that isn't supported yet: typicode/husky#245.ref CORE-1846