Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
1–10 of 15 posts
Re: Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
#2Re: Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
#3Before i commit, i run local tests to be sure that my code is ok (with jshint, ...). Normally i work with my local branch before i push it to other developers.
Why should i share unfinished untested code to others?
Or is pre-commit a kind of local history (like Eclipse holds it in background for every file)?
Re: Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
#4I (think i) understand it, but i did not understand the workflow. Before i commit, i run local tests to be sure that my code is ok (with jshint, ...). Normally i work with my local branch before i push it to other developers. Why should i share unfinished untested code to others? Or is pre-commit a kind of local history (like Eclipse holds it in background for every file)?
Re: Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
#5I (think i) understand it, but i did not understand the workflow. Before i commit, i run local tests to be sure that my code is ok (with jshint, ...). Normally i work with my local branch before i push it to other developers. Why should i share unfinished untested code to others? Or is pre-commit a kind of local history (like Eclipse holds it in background for every file)?
Git has the concept of "pre-commit hooks" which is a script that is run (by git itself) whenever you run "git commit", before your changes actually land in the repository. This can be used to (for example) run your local tests for you, as a sanity check.
However, your hooks are configured on a per-repository basis, and not transferred when you clone. So you would need to configure these manually each time you clone. It's easy to forget to set up the hook with all the things you need to run.
This tool is to help alleviate some of the pain in this, by having a configuration file to set up all the necessary hooks, as well as having a library of default hooks (whitespace checks, etc).
Re: Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
#6Might be of use to someone.
Re: Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
#7 git-hooks provide a way to manage and share your hooks using three+ locations:
User hooks, installed in ~/.git_hooks/
Project hooks, installed in .git/git_hooks/ in a project.
Global hooks, specified with the hooks.global configuration option.
Another very real problem with any hooks solution is that it must be enabled in each repository. Users frequently either don't do it or forget to do it in all of the repositories. Running git hooks --installglobal will force any new git repository or any git repository you clone to have a reminder to install git hooks. (It can't be on by default for security reasons of course.)Re: Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
#8For example we have this for refreshing redmine:
#!/bin/sh
PROJ=""
while [ $# -gt 0 ] ; do
case $1 in
--project)
shift
PROJ="&id=$1"
shift
;;
esac
done
echo $"Refreshing Redmine"
curl -s -o /dev/null "http://issues.qbixstaging.com/sys/fetch_changesets?key=jI$
and here is our PHP syntax check: #!/bin/sh
### Configuration
HGBIN="/usr/bin/hg"
phpPath="/usr/bin/php"
tmpstyle=`/bin/mktemp -t`
### hg log style file
cat > $tmpstyle &2
echo $res 1>&2
exit 1
fi
done
rm $tmpstyle
finally here is one for JS: #!/bin/sh
### Configuration
HGBIN="/usr/bin/hg"
jshPath="/usr/local/bin/jshint"
tmpstyle=`/bin/mktemp -t`
### hg log style file
cat > $tmpstyle &2
echo $res 1>&2
exit 1
fi
if [ $st -gt 1 ] ; then
exit 1
fi
done
rm $tmpstyleRe: Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
#9Even thought pre-commit is written in python we really don't care about the language that was used to write the hook/linter. If there's a good linter out there written in ruby, you should be able to use it and not have to install ruby/gems/etc. With pre-commit you just say you want scss-lint (https://github.com/causes/scss-lint) in your pre-commit config file and run pre-commit install. When you commit, pre-commit downloads, install scss-lint (without root) and runs the hook against the files you've changed.
Currently we support ruby, node and python and we definitely want to expand the system to support linters in other languages like Go, C/C++ and PHP. We'd really like to support all of these linters - https://github.com/showcases/clean-code-linters.
Ken & Anthony
Re: Show HN: Pre-commit – A framework for managing multi-language pre-commit hooks
#10This is cool but why do we need it if Mercurial already supports pre-commit hooks? For example we have this for refreshing redmine: #!/bin/sh PROJ="" while [ $# -gt 0 ] ; do case $1 in --project) shift PROJ="&id=$1" shift ;; esac done echo $"Refreshing Redmine" curl -s -o /dev/null "http://issues.qbixstaging.com/sys/fetch_changesets?key=jI$ and here is our PHP syntax check: #!/bin/sh ### Configuration HGBIN="/usr/bin…
aside: It would be cool to support mercurial in the future :D