Skip to content

bash exit 1 doesn't work #71

@aliasadidev

Description

@aliasadidev

Version

0.5.4

Details

The tool doesn't care about the errors, the information attached into Steps to reproduce section

Steps to reproduce

setup and config

dotnet new console -n App1
git init

dotnet new tool-manifest
dotnet tool install Husky
dotnet husky install

dotnet husky add pre-commit -c "dotnet husky run --group pre-commit'"

add .editorconfig file

https://github.com/RehanSaeed/EditorConfig/blob/main/.editorconfig

pre-commit file content

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

dotnet husky run --group pre-commit

# I want to run a condition here, e.g if dotnet format updated some files then the git commit would be rejected 
exit 1 # <============ didn't work for c# files

Task-runner.json

{
  "tasks": [
    {
      "name": "Dotnet Format",
      "command": "cmd",
      "pathMode": "relative",
      "args": [
        "/c",
        "dotnet",
        "format",
        "--include",
        "${staged}"
      ],
      "group": "pre-commit"
    }
  ]
}

Update program.cs (with bad format)

using App1;

internal class Program
{
    private static void Main(string[] args)
    {
   int x=100;
int xx=x;
    }
}

Add all files

git add .
git commit -m "init"

The problem is when I send the git commit, it will be stored successfully, but it shouldn't be.

image

As you can see the file should be placed in the change section.

image

Dotnet format worked correctly (added the file as a new file changed)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions