jish/pre-commit

Cannot run hooks from SourceTree

Closed this issue · 2 comments

RVM

Since terminals and full .apps have completely different environments (and PATH variables) the default path used by SourceTree did not expose rvm to SourceTree. In order to ensure SourceTree knows about rvm we added the following a conditional to the hook to add the rvm path if it wasn't included already. This exposed rvm so the hook could successfully execute rvm.

RVM_PATH=$HOME/.rvm/bin
if [ -d "$RVM_PATH" ] && [[ ! $PATH =~ (^|:)$RVM_PATH(:|$) ]]; then
  PATH+=:$RVM_PATH
fi

LC_CTYPE

We are running on Mac OSX 10.11.6. SourceTree's default encoding is C rather than UTF-8 which caused an encoding issue in ExecJS.

gems/execjs-2.2.1/lib/execjs/encoding.rb:22

Enforcing a LC_CTYPE of UTF-8 resolved the issue.

export LC_CTYPE="en_US.UTF-8"

Ruby Version 2.1.2

jish commented

Cool, thanks for the information. It sounds like you have everything working properly, then?

Would it be helpful to create another hook template that automatically configures SourceTree properly? https://github.com/jish/pre-commit/tree/master/templates/hooks

$ pre-commit install --source-tree
jish commented

I have released a new version of the gem that supports the --sourcetree option.

pre-commit install --sourcetree

cf. #248