Skip to content

Proposal: add git hooks to the repo #37900

@am11

Description

@am11

git hooks are useful to automate validation of certain common practices and conventions used by the repo, which maybe specified in the docs, but still (unintentionally) violated in changes being committed.

git hooks scripts are cross-platform (hint: git-win has sh.exe/bash.exe and so on) and thus have access to everything as the executing environment.

In dotnet/runtime, we can use them to validate:

  • code being checked in inside eng/common, which is the mirror directory sourced from arcade.
  • native dependencies (brotli, libunwind etc.) code is being updated without updating their corresponding {name}-version.txt file.
  • format of commit message first (subject) line exceeding certain threshold.
  • jit code is updated and jit-format's output is not clean.
  • C# code is update, dotnet-format is available, but git show --name-only --pretty="" | xargs dotnet-format --include is not clean.
  • change has invalid trailing whitespaces.
  • change has new file without proper Unix-y EOF.
  • more?

git hooks can be installed as part of bootstrap, e.g. ./install-hooks script which can be ran manually as well as invoked by top-level ./build script.

cc @janvorli, @jkotas, @danmosemsft

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions