Skip to content

Commit

Permalink
Add git hook for formating (#2224)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton authored Sep 8, 2022
1 parent 5ecf7b9 commit b612426
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

FILES=$(git diff --cached --name-only --diff-filter=ACM "*.cs")
if [ -n "$FILES" ]
then
dotnet format ./bitwarden-server.sln --no-restore --include $FILES
echo "$FILES" | xargs git add
fi
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -75,15 +75,11 @@ No grant of any rights in the trademarks, service marks, or logos of Bitwarden i

### Dotnet-format

We recently migrated to using dotnet-format as code formatter. All previous branches will need to updated to avoid large merge conflicts using the following steps:
Consider installing our git pre-commit hook for automatic formatting.

1. Check out your local Branch
2. Run `git merge 61dc65aa598b1f492d2f0222bb7bf0dd15d116f5`
3. Resolve any merge conflicts, commit.
4. Run `dotnet tool run dotnet-format`
5. Commit
6. Run `git merge -Xours 23b0a1f9df25058ab29785ecad9a233113c10889`
7. Push
```bash
git config --local core.hooksPath .git-hooks
```

### File Scoped Namespaces

0 comments on commit b612426

Please sign in to comment.