Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #777 from leotsarev/patch-1
Create integrations.md
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Integrations | ||
Collection of advice how to auto check/format. Every sample expects dotnet format installed as local tool. | ||
|
||
## Pre-commit hook to reformat | ||
|
||
Create file `.git/pre-commit` with following contents: | ||
```sh | ||
#!/bin/sh | ||
LC_ALL=C | ||
# Select files to format | ||
FILES=$(git diff --cached --name-only --diff-filter=ACM "*.cs" | sed 's| |\\ |g') | ||
[ -z "$FILES" ] && exit 0 | ||
|
||
# Format all selected files | ||
echo "$FILES" | cat | xargs | sed -e 's/ /,/g' | xargs dotnet format --include | ||
|
||
# Add back the modified files to staging | ||
echo "$FILES" | xargs git add | ||
|
||
exit 0 | ||
|
||
``` | ||
|
||
These instructions originally authored by [randulakoralage82](https://medium.com/@randulakoralage82/format-your-net-code-with-git-hooks-a0dc33f68048). | ||
|
||
|
||
## Check on PR in Azure Dev Ops | ||
|
||
Add following to your build file: | ||
|
||
```yaml | ||
- task: DotNetCoreCLI@2 | ||
displayName: 'Install dotnet tools' | ||
inputs: | ||
command: 'custom' | ||
custom: 'tool' | ||
arguments: 'restore' | ||
|
||
- task: DotNetCoreCLI@2 | ||
displayName: 'dotnet-format' | ||
inputs: | ||
command: 'custom' | ||
custom: 'format' | ||
arguments: '--check' | ||
``` | ||
|
||
|
||
These instructions originally authored by [leotsarev](https://github.com/joinrpg/joinrpg-net/). |