jurassiscripts / velociraptor

The npm-style script runner for Deno

Home Page:https://velociraptor.run

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pre-commit hook fails in fish shell

awmottaz opened this issue · comments

Using v1.0.2 of velociraptor.

Given this scripts file:

#scripts.yml
scripts:
  fmt:
    cmd: deno fmt --ignore=deno_dir
    gitHook: pre-commit

I get the following error when trying to commit:

$ git commit
fish: Unsupported use of '='. In fish, please use 'set GIT_ARGS ("$@")'.

error: Failed at the pre-commit script

Hey @awmottaz, thanks for reporting this!
I haven't had the occasion to properly test git hooks in fish, let's say that for now they're only "officially" supported in sh/bash/zsh (I'll add a note to the docs about this), but this could be a good occasion to add fish support! I'm super busy atm but I'm happy to accept a PR in case you want to help out 🙂
To give a little context on the spot that is causing the error: in order to pass hook arguments to scripts we use a shell array variable GIT_ARGS (this is because appending arguments directly after user scripts can easily break them).
I guess detecting the use of fish and conditionally replacing the assignment with a set command should be enough to fix this.

Thanks! I'm happy take a look.

In the meantime, I found a workaround by setting the shell that Velociraptor should use for Git Hooks:

set -x VR_SHELL "/bin/sh"

Is there a good place to document this (and other) env variables that Velociraptor supports?

Those are documented here. Git hooks are just another way to run regular vr scripts so the same rules about shell resolving apply.

Hi @awmottaz! A preview of fish support for git hooks is now live on develop. If you want to help test it, install vr from the develop branch:

$ deno install --reload -qAfn vr https://raw.githubusercontent.com/jurassiscripts/velociraptor/develop/cli.ts

Fish support is now live in v1.3.0