-
-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathcleanupcode.ps1
More file actions
38 lines (31 loc) · 1.93 KB
/
cleanupcode.ps1
File metadata and controls
38 lines (31 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#Requires -Version 7.4
# This script reformats (part of) the codebase to make it compliant with our coding guidelines.
param(
# Git branch name or base commit hash to reformat only the subset of changed files. Omit for all files.
[string] $revision
)
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
dotnet tool restore
dotnet restore /p:NuGetAudit=false
dotnet build --no-restore --configuration Release /p:RunAnalyzers=false
$solutionFile = 'JsonApiDotNetCore.slnx'
if ($revision) {
$headCommitHash = git rev-parse HEAD
$baseCommitHash = git rev-parse $revision
if ($baseCommitHash -eq $headCommitHash) {
Write-Output "Running code cleanup on staged/unstaged files."
dotnet jb cleanupcode --version
dotnet regitlint -s $solutionFile --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --no-updates --jb --properties:"Configuration=Release;RunAnalyzers=false;NuGetAudit=false" --jb --verbosity=WARN -f staged,modified
}
else {
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash, including staged/unstaged files."
dotnet jb cleanupcode --version
dotnet regitlint -s $solutionFile --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --no-updates --jb --properties:"Configuration=Release;RunAnalyzers=false;NuGetAudit=false" --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash
}
}
else {
Write-Output "Running code cleanup on all files."
dotnet jb cleanupcode --version
dotnet regitlint -s $solutionFile --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --no-updates --jb --properties:"Configuration=Release;RunAnalyzers=false;NuGetAudit=false" --jb --verbosity=WARN
}