You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- dotnet-format / dotnet-format-check: walk up looking for .sln/.csproj/
.fsproj/.vbproj before invoking; warn-and-skip if no MSBuild project found
(avoids the "Could not find a MSBuild project file" crash in repos with no
.NET project).
- steep: warn-and-skip when no Steepfile is present in any ancestor (avoids
"Cannot find Steepfile" when a Gemfile exists but no Steep config).
- rubocop / rubocop-lint: when a Gemfile is found in an ancestor, export
BUNDLE_GEMFILE so `bundle exec rubocop` works from PWD without "Could not
locate Gemfile". Fall back to system rubocop.
- php-cs-fixer: auto-pass --config=.php-cs-fixer.dist.php (or .php-cs-fixer.php)
when present so prek's multi-file invocations don't trip "For multiple paths
config parameter is required."
- hadolint: on Darwin-arm64, prefer system-installed hadolint (Homebrew) and
warn-and-skip if absent (the x86_64 binary segfaults under Rosetta on Apple
Silicon, no native arm64 binary upstream).
Copy file name to clipboardExpand all lines: hooks/dotnet-format-check/run.sh
+30-1Lines changed: 30 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,39 @@
4
4
# is not on PATH, prints a skip warning and exits 0.
5
5
set -euo pipefail
6
6
7
-
if!command -v dotnet >/dev/null 2>&1;then
7
+
if!command -v dotnet >/dev/null 2>&1;then
8
8
printf'kreuzberg-pre-commit-hooks: skipping dotnet-format-check — `dotnet` not found on PATH.\n'>&2
9
9
printf' install the .NET SDK 6+ to enable this hook.\n'>&2
10
10
exit 0
11
11
fi
12
12
13
+
# `dotnet format` requires an MSBuild project (.sln/.csproj/.fsproj/.vbproj).
14
+
_find_dotnet_project() {
15
+
local d="${1:-${PWD}}"
16
+
while [[ "${d}"!="/"&&"${d}"!="."&&-n"${d}" ]];do
17
+
ifcompgen -G "${d}"/*.sln > /dev/null \
18
+
||compgen -G "${d}"/*.csproj > /dev/null \
19
+
||compgen -G "${d}"/*.fsproj > /dev/null \
20
+
||compgen -G "${d}"/*.vbproj > /dev/null;then
21
+
return 0
22
+
fi
23
+
d="$(dirname "${d}")"
24
+
done
25
+
return 1
26
+
}
27
+
28
+
start="${PWD}"
29
+
if [[ $#-gt 0 ]];then
30
+
forargin"$@";do
31
+
[[ "${arg}"== -* ]] &&continue
32
+
start="$(dirname "${arg}")"
33
+
break
34
+
done
35
+
fi
36
+
37
+
if! _find_dotnet_project "${start}";then
38
+
printf'kreuzberg-pre-commit-hooks: skipping dotnet-format-check — no MSBuild project file (.sln/.csproj/.fsproj/.vbproj) found in or above %s.\n'"${start}">&2
Copy file name to clipboardExpand all lines: hooks/dotnet-format/run.sh
+33-1Lines changed: 33 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,42 @@
4
4
# and exits 0.
5
5
set -euo pipefail
6
6
7
-
if!command -v dotnet >/dev/null 2>&1;then
7
+
if!command -v dotnet >/dev/null 2>&1;then
8
8
printf'kreuzberg-pre-commit-hooks: skipping dotnet-format — `dotnet` not found on PATH.\n'>&2
9
9
printf' install the .NET SDK 6+ to enable this hook.\n'>&2
10
10
exit 0
11
11
fi
12
12
13
+
# `dotnet format` requires an MSBuild project (.sln/.csproj/.fsproj/.vbproj).
14
+
# Walk up from PWD (or the first input file's dirname) so polyrepos with the
15
+
# .NET project tucked under packages/csharp/ still work; warn-and-skip if none
16
+
# is found in any ancestor.
17
+
_find_dotnet_project() {
18
+
local d="${1:-${PWD}}"
19
+
while [[ "${d}"!="/"&&"${d}"!="."&&-n"${d}" ]];do
20
+
ifcompgen -G "${d}"/*.sln > /dev/null \
21
+
||compgen -G "${d}"/*.csproj > /dev/null \
22
+
||compgen -G "${d}"/*.fsproj > /dev/null \
23
+
||compgen -G "${d}"/*.vbproj > /dev/null;then
24
+
return 0
25
+
fi
26
+
d="$(dirname "${d}")"
27
+
done
28
+
return 1
29
+
}
30
+
31
+
start="${PWD}"
32
+
if [[ $#-gt 0 ]];then
33
+
forargin"$@";do
34
+
[[ "${arg}"== -* ]] &&continue
35
+
start="$(dirname "${arg}")"
36
+
break
37
+
done
38
+
fi
39
+
40
+
if! _find_dotnet_project "${start}";then
41
+
printf'kreuzberg-pre-commit-hooks: skipping dotnet-format — no MSBuild project file (.sln/.csproj/.fsproj/.vbproj) found in or above %s.\n'"${start}">&2
0 commit comments