Skip to content

Commit ad440c0

Browse files
committed
Make pushFilter filter out just the positive matches
Previously, it would remove all paths if even a single one matched.
1 parent 2aa3f34 commit ad440c0

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

dist/main/index.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -7964,8 +7964,17 @@ async function registerPostBuildHook(cachixBin, daemonDir) {
79647964
79657965
PUSH_FILTER="${pushFilter}"
79667966
7967-
if [ -n "$PUSH_FILTER" ]; then
7968-
OUT_PATHS=$(echo "$OUT_PATHS" | grep -vEe "$PUSH_FILTER")
7967+
function filterPaths {
7968+
local regex=$1
7969+
local paths=$2
7970+
7971+
for path in $paths; do
7972+
echo $path | grep -vEe $regex
7973+
done | xargs
7974+
}
7975+
7976+
if [[ -n $PUSH_FILTER ]]; then
7977+
OUT_PATHS=$(filterPaths $PUSH_FILTER "$OUT_PATHS")
79697978
fi
79707979
79717980
exec ${cachixBin} daemon push \

dist/main/push-paths.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@ set -euo pipefail
33

44
cachix=$1 cachixArgs=${2:--j8} cache=$3 pathsToPush=$4 pushFilter=$5
55

6-
if [[ $pathsToPush == "" ]]; then
6+
filterPaths() {
7+
local regex=$1
8+
local paths=$2
9+
10+
for path in $paths; do
11+
echo $path | grep -vEe $regex
12+
done | xargs
13+
}
14+
15+
if [[ -z $pathsToPush ]]; then
716
pathsToPush=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh))
817

9-
if [[ $pushFilter != "" ]]; then
10-
pathsToPush=$(echo "$pathsToPush" | grep -vEe "$pushFilter")
18+
if [[ -n $pushFilter ]]; then
19+
pathsToPush=$(filterPaths $pushFilter "$pathsToPush")
1120
fi
1221
fi
1322

src/main.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,17 @@ async function registerPostBuildHook(cachixBin: string, daemonDir: string) {
283283
284284
PUSH_FILTER="${pushFilter}"
285285
286-
if [ -n "$PUSH_FILTER" ]; then
287-
OUT_PATHS=$(echo "$OUT_PATHS" | grep -vEe "$PUSH_FILTER")
286+
function filterPaths {
287+
local regex=$1
288+
local paths=$2
289+
290+
for path in $paths; do
291+
echo $path | grep -vEe $regex
292+
done | xargs
293+
}
294+
295+
if [[ -n $PUSH_FILTER ]]; then
296+
OUT_PATHS=$(filterPaths $PUSH_FILTER "$OUT_PATHS")
288297
fi
289298
290299
exec ${cachixBin} daemon push \

0 commit comments

Comments
 (0)