Skip to content

Commit

Permalink
Merge pull request #777 from leotsarev/patch-1
Browse files Browse the repository at this point in the history
Create integrations.md
  • Loading branch information
JoeRobich committed Aug 26, 2020
2 parents 6559f1b + 29bbf44 commit 6eae22f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docs/integrations.md
@@ -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/).

0 comments on commit 6eae22f

Please sign in to comment.