Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in GitKraken, git environment variable not set in commit hooks

Tags:

gitkraken

I'm trying to use a commit hook that runs eslint. To hook uses GIT_DIR to find the package local eslint and related eslint configs. Like this:

ESLINT_PATH="${GIT_DIR}/../node_modules/.bin/eslint"

From the command line, this works fine. GIT_DIR is set and everybody is happy. In GitKraken though, GIT_DIR is missing. In fact, no git environment vars are set. I ran env in the hook and looked at the output.

Is this normal behavior for GitKraken? Is there some hidden config that I'm missing?

I can mod the script, so if there's a more "proper" way to do this, I'm all ears.

like image 794
leff Avatar asked Jun 07 '17 16:06

leff


1 Answers

I know this is a bit late to the party, but I just ran into a similar issue, and I hope this will help any future inquires.

This information is accurate for GitKraken 4.2.2, as I have not tested this with a newer version.

GitKraken does not actually use Git. It works exactly like Git, yes, but it doesn't actually require Git to be installed on your system. As per the main GitKraken download page here:

It works directly with your repositories with no dependencies—you don’t even need to have Git installed on your system. GitKraken is built with NodeGit, a Git framework that is primarily developed and maintained by members of the GitKraken development team.

As such, adding the Git hooks feature, to begin with, was (according to the GitKraken team) challenging. From the "April 3, 2017 2.3.0 Release Notes":

Git hooks! One thing that has prevented some users and teams from being able to adopt GitKraken is the lack of Git hooks support. Until today! You can now create custom scripts that fire off at certain points during Git processes. GitKraken does not require that you install Git on your system, so until now, that independence had meant no Git hooks support. But, with a lot of blood, sweat and tears, v2.3 allows you to hook your way to a bounty of control over your Git actions!

So, you won't be able to use Git environment variables since "regular" Git isn't actually being used under the hood.

In fact, a lot of the more complicated Git features won't necessarily be supported unless specifically mentioned.

like image 113
Rezkin Avatar answered Oct 19 '22 00:10

Rezkin