Skip to content

Commit e0020f6

Browse files
committed
feat(sentinels): add .NET project build directory exclusions
Exclude bin/ and obj/ directories when *.csproj (C#) or *.fsproj (F#) project files are present, using glob sentinel patterns. Inspired by stevegrunwell#87, props @guigomesa.
1 parent 64834be commit e0020f6

5 files changed

Lines changed: 67 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2626
* Exclude Elm packages (`elm-stuff`)
2727
* Exclude Godot 4 editor cache (`.godot`)
2828
* Exclude R renv environment (`renv`)
29+
* Exclude .NET build output (`bin`, `obj`) when `*.csproj` or `*.fsproj` project files are present (inspired by [stevegrunwell/asimov#87], props @guigomesa)
2930
* Added `make install` and `make uninstall` targets for streamlined setup and removal ([#35], props @sylver)
3031
* Added `scripts/uninstall.sh` to cleanly remove Asimov and its launchd schedule ([#35], props @sylver)
3132
* Added common interval reference comments to `com.stevegrunwell.asimov.plist` ([#35], props @sylver)
@@ -117,3 +118,4 @@ Initial public release.
117118
[#55]: https://github.com/stevegrunwell/asimov/pull/55
118119
[#35]: https://github.com/stevegrunwell/asimov/pull/35
119120
[#56]: https://github.com/stevegrunwell/asimov/pull/56
121+
[stevegrunwell/asimov#87]: https://github.com/stevegrunwell/asimov/pull/87

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Asimov recognizes dependency directories across **30+ patterns** in these ecosys
3838
| **PHP** | `vendor` |
3939
| **Ruby** | `vendor` |
4040
| **Java / Kotlin / Scala** | `.gradle`, `build`, `target` |
41+
| **.NET (C# / F#)** | `bin`, `obj` |
4142
| **Swift / Apple** | `.build`, `Carthage`, `Pods` |
4243
| **Dart / Flutter** | `.dart_tool`, `.packages`, `build` |
4344
| **Elixir** | `deps`, `_build`, `.build` |

asimov

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ readonly ASIMOV_VENDOR_DIR_SENTINELS=(
7171
'target deps.edn' # Clojure CLI
7272
'.cpcache deps.edn' # Clojure CLI classpath cache
7373
'.shadow-cljs shadow-cljs.edn' # Shadow-CLJS (ClojureScript)
74+
'bin *.csproj' # .NET C# build output
75+
'obj *.csproj' # .NET C# intermediate output
76+
'bin *.fsproj' # .NET F# build output
77+
'obj *.fsproj' # .NET F# intermediate output
7478
'vendor composer.json' # Composer (PHP)
7579
'vendor Gemfile' # Bundler (Ruby)
7680
'vendor go.mod' # Go Modules (Golang)
@@ -130,13 +134,25 @@ for i in "${ASIMOV_VENDOR_DIR_SENTINELS[@]}"; do
130134
#
131135
# For example, when looking at a /vendor directory, we may choose to
132136
# ensure a composer.json file is available.
133-
find_parameters_vendor+=( -or \( \
134-
-type d \
135-
-name "${_exclude_name}" \
136-
-execdir test -e "${_sibling_sentinel_name}" \; \
137-
-prune \
138-
-print \
139-
\) )
137+
#
138+
# Glob sentinels (containing *) use ls -d; literal sentinels use test -e.
139+
if [[ "${_sibling_sentinel_name}" == *'*'* ]]; then
140+
find_parameters_vendor+=( -or \( \
141+
-type d \
142+
-name "${_exclude_name}" \
143+
-execdir sh -c "ls -d ${_sibling_sentinel_name} >/dev/null 2>&1" \; \
144+
-prune \
145+
-print \
146+
\) )
147+
else
148+
find_parameters_vendor+=( -or \( \
149+
-type d \
150+
-name "${_exclude_name}" \
151+
-execdir test -e "${_sibling_sentinel_name}" \; \
152+
-prune \
153+
-print \
154+
\) )
155+
fi
140156
done
141157

142158
printf '\n\033[0;36mFinding dependency directories with corresponding definition files…\033[0m\n'

tests/behavior.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ load test_helper
3636
[[ "$(count_exclusions)" -eq 0 ]]
3737
}
3838

39+
@test "does not exclude bin without any .NET project file" {
40+
mkdir -p "${HOME}/Code/My-Project/bin"
41+
run_asimov
42+
refute_excluded "${HOME}/Code/My-Project/bin"
43+
[[ "$(count_exclusions)" -eq 0 ]]
44+
}
45+
3946
# =============================================================================
4047
# Multi-match and deduplication
4148
# =============================================================================

tests/sentinels.bats

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,40 @@ load test_helper
292292
[[ "$(count_exclusions)" -eq 1 ]]
293293
}
294294

295+
# --- .NET ---
296+
297+
@test ".NET C#: excludes bin when *.csproj is present" {
298+
mkdir -p "${HOME}/Code/My-Project/bin"
299+
echo "sentinel" > "${HOME}/Code/My-Project/MyApp.csproj"
300+
run_asimov
301+
assert_excluded "${HOME}/Code/My-Project/bin"
302+
[[ "$(count_exclusions)" -eq 1 ]]
303+
}
304+
305+
@test ".NET C#: excludes obj when *.csproj is present" {
306+
mkdir -p "${HOME}/Code/My-Project/obj"
307+
echo "sentinel" > "${HOME}/Code/My-Project/MyApp.csproj"
308+
run_asimov
309+
assert_excluded "${HOME}/Code/My-Project/obj"
310+
[[ "$(count_exclusions)" -eq 1 ]]
311+
}
312+
313+
@test ".NET F#: excludes bin when *.fsproj is present" {
314+
mkdir -p "${HOME}/Code/My-Project/bin"
315+
echo "sentinel" > "${HOME}/Code/My-Project/MyApp.fsproj"
316+
run_asimov
317+
assert_excluded "${HOME}/Code/My-Project/bin"
318+
[[ "$(count_exclusions)" -eq 1 ]]
319+
}
320+
321+
@test ".NET F#: excludes obj when *.fsproj is present" {
322+
mkdir -p "${HOME}/Code/My-Project/obj"
323+
echo "sentinel" > "${HOME}/Code/My-Project/MyApp.fsproj"
324+
run_asimov
325+
assert_excluded "${HOME}/Code/My-Project/obj"
326+
[[ "$(count_exclusions)" -eq 1 ]]
327+
}
328+
295329
# --- PHP ---
296330

297331
@test "Composer: excludes vendor when composer.json is present" {

0 commit comments

Comments
 (0)