From f6ccd2f8027343a11186e5dd16668b8bcce5e951 Mon Sep 17 00:00:00 2001 From: Ruairidh MacLeod Date: Mon, 2 Nov 2020 13:20:09 +0000 Subject: [PATCH 1/9] add .pre-commit-hooks.yaml --- .pre-commit-hooks.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000000..2f3559f4e9 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,7 @@ +--- + +- id: dotnet-format + name: dotnet format + language: dotnet + types: ['c#'] + entry: dotnet-format From f48df4e195f38a493f9944d4d36bb2c5ed7cc19e Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Thu, 11 Mar 2021 20:46:43 -0800 Subject: [PATCH 2/9] Update integrations.md As requested on the original PR (https://github.com/dotnet/format/pull/872) --- docs/integrations.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/integrations.md b/docs/integrations.md index db833b3f30..24e2aba123 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -1,7 +1,7 @@ # Integrations Collection of advice how to auto check/format. Every sample expects dotnet format installed as local tool. -## Pre-commit hook to reformat +## Git pre-commit hook to reformat Create file `.git/pre-commit` with following contents: ```sh @@ -46,3 +46,17 @@ Add following to your build file: These instructions originally authored by [leotsarev](https://github.com/joinrpg/joinrpg-net/). + + +## [pre-commit.com](https://pre-commit.com/) hook to reformat + +Add the following block to the `repos` section of your `.pre-commit-config.yaml` file: + +``` +- repo: https://github.com/dotnet/format + rev: "v5.0.211103" # Or a more recent commit sha + hooks: + - id: dotnet-format + args: [--include] +``` +These instructions originally authored by [rkm](https://github.com/rkm) From dc4794e628f103312e270fad2eaa8d1d1ba517c6 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Thu, 11 Mar 2021 20:51:42 -0800 Subject: [PATCH 3/9] Update note about installation. --- docs/integrations.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/integrations.md b/docs/integrations.md index 24e2aba123..f524128548 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -1,5 +1,5 @@ # Integrations -Collection of advice how to auto check/format. Every sample expects dotnet format installed as local tool. +Collection of advice how to auto check/format. Every sample expects dotnet format installed as local tool, unless otherwise noted. ## Git pre-commit hook to reformat @@ -59,4 +59,6 @@ Add the following block to the `repos` section of your `.pre-commit-config.yaml` - id: dotnet-format args: [--include] ``` +Note that this will install dotnet format using the system installation of the dotnet CLI. See the [pre-commit.com documentation](https://pre-commit.com/#dotnet) for more details. + These instructions originally authored by [rkm](https://github.com/rkm) From 0d29b1a419929071ed9515bd95ad1defeac39609 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Thu, 11 Mar 2021 20:56:55 -0800 Subject: [PATCH 4/9] Add --include to entry --- .pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 2f3559f4e9..edc9e8fe7d 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -4,4 +4,4 @@ name: dotnet format language: dotnet types: ['c#'] - entry: dotnet-format + entry: dotnet-format --include From eef06c48f34a63d7c8c7bf714e9163e134e6d8a9 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Thu, 11 Mar 2021 20:57:31 -0800 Subject: [PATCH 5/9] Remove args (now part of entry) --- docs/integrations.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/integrations.md b/docs/integrations.md index f524128548..ed85376f61 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -57,7 +57,6 @@ Add the following block to the `repos` section of your `.pre-commit-config.yaml` rev: "v5.0.211103" # Or a more recent commit sha hooks: - id: dotnet-format - args: [--include] ``` Note that this will install dotnet format using the system installation of the dotnet CLI. See the [pre-commit.com documentation](https://pre-commit.com/#dotnet) for more details. From aa3f96fc8db5b0a7b99124e839f8e7eb1b3a7300 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Thu, 11 Mar 2021 21:02:40 -0800 Subject: [PATCH 6/9] Clarify install scope --- docs/integrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integrations.md b/docs/integrations.md index ed85376f61..8b2236742c 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -58,6 +58,6 @@ Add the following block to the `repos` section of your `.pre-commit-config.yaml` hooks: - id: dotnet-format ``` -Note that this will install dotnet format using the system installation of the dotnet CLI. See the [pre-commit.com documentation](https://pre-commit.com/#dotnet) for more details. +Note that this will install dotnet format to an isolated environment, using the system installation of the dotnet CLI. See the [pre-commit.com documentation](https://pre-commit.com/#dotnet) for more details. These instructions originally authored by [rkm](https://github.com/rkm) From 5d2be85276608d532875e7f0479c7826a73e4651 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Thu, 11 Mar 2021 21:04:54 -0800 Subject: [PATCH 7/9] yaml highlighting --- docs/integrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integrations.md b/docs/integrations.md index 8b2236742c..1e69453c9f 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -52,7 +52,7 @@ These instructions originally authored by [leotsarev](https://github.com/joinrpg Add the following block to the `repos` section of your `.pre-commit-config.yaml` file: -``` +```yaml - repo: https://github.com/dotnet/format rev: "v5.0.211103" # Or a more recent commit sha hooks: From 007eb48269adc04b4f8b5233b3988e8040a31066 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Sun, 14 Mar 2021 15:30:29 -0700 Subject: [PATCH 8/9] Update rev --- docs/integrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integrations.md b/docs/integrations.md index 1e69453c9f..15ae9f017a 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -54,7 +54,7 @@ Add the following block to the `repos` section of your `.pre-commit-config.yaml` ```yaml - repo: https://github.com/dotnet/format - rev: "v5.0.211103" # Or a more recent commit sha + rev: "" # Specify a tag or sha here, or run "pre-commit autoupdate" hooks: - id: dotnet-format ``` From 2bb839eb1a2d36b59eec26aed590b791f009c795 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Sun, 14 Mar 2021 15:31:05 -0700 Subject: [PATCH 9/9] Check *.vb too --- .pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index edc9e8fe7d..79df60165c 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -3,5 +3,5 @@ - id: dotnet-format name: dotnet format language: dotnet - types: ['c#'] + types_or: ['c#', 'vb'] entry: dotnet-format --include