Skip to content

Support install not in .git root #103

@jods4

Description

@jods4

Details

Currently, husky checks that it's being installed in the repository root, i.e. cwd contains a .git folder.

Some repository contain more than a .net solution, it's not uncommon to have other folders at root such as docs, infra, front-end, etc. In our setup, dotnet solution and .config local tools live in a Source folder, under root.

The issue with this is that:

  1. Local dotnet tool can't run outside Source because they're local and do not exist outside of that folder.
  2. Local tool Husky can't run inside Source because it requires .git in the same folder where it runs.

As 1. and 2. are mutually exclusive, there's no working configuration :(

Note

Husky -- the NPM project that inspired Husky.Net -- has a "How to" for this topic in its documentation:
https://typicode.github.io/husky/how-to.html#project-not-in-git-root-directory

Their solution is simply to change working directory appropriately in install script and hook.
The blocker is that whereas cd .. & husky works in NPM scripts, there's no way parameter to change the working directory in dotnet run, so husky init can't be run in a different cwd.

Suggested solution

Add a --cwd parameter to install command, so that the working directory can be changed before it runs:

dotnet husky install --cwd ../..

The reverse cd command should be inferred automatically (using Path.GetRelativePath) and introduced in hook script so that they run in the correct folder (otherwise dotnet husky & other local .net tool tasks will not be found).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions