Skip to content

Commit

Permalink
Make pushFilter filter out just the positive matches
Browse files Browse the repository at this point in the history
Previously, it would remove all paths if even a single one matched.
  • Loading branch information
sandydoo committed Apr 25, 2024
1 parent 2aa3f34 commit 226ef86
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
13 changes: 11 additions & 2 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7964,8 +7964,17 @@ async function registerPostBuildHook(cachixBin, daemonDir) {
PUSH_FILTER="${pushFilter}"
if [ -n "$PUSH_FILTER" ]; then
OUT_PATHS=$(echo "$OUT_PATHS" | grep -vEe "$PUSH_FILTER")
function filterPaths {
local regex=$1
local paths=$2
for path in $paths; do
echo $path | grep -vEe $regex
done | xargs
}
if [[ -n $PUSH_FILTER ]]; then
OUT_PATHS=$(filterPaths $PUSH_FILTER "$OUT_PATHS")
fi
exec ${cachixBin} daemon push \
Expand Down
15 changes: 12 additions & 3 deletions dist/main/push-paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ set -euo pipefail

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

if [[ $pathsToPush == "" ]]; then
function filterPaths {
local regex=$1
local paths=$2

for path in $paths; do
echo $path | grep -vEe $regex
done | xargs
}

if [[ -z $pathsToPush ]]; then
pathsToPush=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh))

if [[ $pushFilter != "" ]]; then
pathsToPush=$(echo "$pathsToPush" | grep -vEe "$pushFilter")
if [[ -n $pushFilter ]]; then
pathsToPush=$(filterPaths $pushFilter "$pathsToPush")
fi
fi

Expand Down
13 changes: 11 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,17 @@ async function registerPostBuildHook(cachixBin: string, daemonDir: string) {
PUSH_FILTER="${pushFilter}"
if [ -n "$PUSH_FILTER" ]; then
OUT_PATHS=$(echo "$OUT_PATHS" | grep -vEe "$PUSH_FILTER")
function filterPaths {
local regex=$1
local paths=$2
for path in $paths; do
echo $path | grep -vEe $regex
done | xargs
}
if [[ -n $PUSH_FILTER ]]; then
OUT_PATHS=$(filterPaths $PUSH_FILTER "$OUT_PATHS")
fi
exec ${cachixBin} daemon push \
Expand Down

0 comments on commit 226ef86

Please sign in to comment.