Skip to content

Commit

Permalink
Allow both quotation style in nix derivations
Browse files Browse the repository at this point in the history
  • Loading branch information
harris-chris committed Jan 3, 2024
1 parent 057eef9 commit dcbb80d
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ test_script*
docs_test/*
test/*-temp
result/*
result/
**/result/
notes/*
11 changes: 5 additions & 6 deletions nix/makePrunedSrc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, source
, filter
, glibcLocales
, lib
}:
stdenv.mkDerivation {
name = "pruned_src";
Expand All @@ -12,18 +13,16 @@ stdenv.mkDerivation {
buildPhase = ''
export LANG="en_US.UTF-8"
mkdir $out
echo $(locale)
echo "treeSurgeon is located: ${treeSurgeon}"
if $(${treeSurgeon}/bin/tree-surgeon to-bash -f '${filter}' -s ${source} > call_out 2> call_err); then
if $(${treeSurgeon}/bin/tree-surgeon to-bash \
-f ${lib.strings.escapeNixString filter} \
-s ${source} > call_out 2> call_err);
then
BASHARR="$(cat call_out)"
cd ${source}
cp --parents $BASHARR $out/
else
echo "is not working; test char is: │"
ERRMSG=$(cat call_err)
echo "Echoing error"
echo "$ERRMSG"
echo "Exiting"
exit 1
fi
'';
Expand Down
2 changes: 0 additions & 2 deletions notes/notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
----------

We have three current issues:
- If you screw up your ts expression in prune, you get crazy error output
- An incorrect filter expression doesn't return a non-zero error code
- Error messages probably still not great
- It does not seem to work with "endsWith '.cpp' (basename file)", does using '' " " '' though
- README is incomplete and the documentation doesn't really describe the command-line options.
Expand Down
2 changes: 1 addition & 1 deletion result
17 changes: 4 additions & 13 deletions src/app/TreeFilter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import Debug.Trace (trace)
import qualified Data.Text as T
import System.Directory.Tree
import System.Exit
import System.IO (hPutStrLn, stderr)
import TextShow
import qualified Lexer as X

Expand Down Expand Up @@ -65,19 +64,15 @@ applyFilterWith :: FileName -> (DirTree FData -> IO()) -> BS.ByteString -> IO ()
applyFilterWith dirname ioF filterStr = do
filteredTreeE <- applyFilter dirname filterStr
case filteredTreeE of
Left (e:_) -> do
hPutStrLn stderr $ trace ("to error message: " <> toErrorMessage filterStr e) (toErrorMessage filterStr e)
exitWith (ExitFailure 1)
Left (e:_) -> die $ toErrorMessage filterStr e
Left [] -> error "Wie ist es moglich"
Right filtered -> ioF filtered

applyFilterWithReproduce :: FileName -> (DirTree FData -> IO()) -> BS.ByteString -> IO ()
applyFilterWithReproduce dirname ioF filterStr = do
filteredTreeE <- applyFilter dirname filterStr
case filteredTreeE of
Left (e:_) -> do
hPutStrLn stderr $ trace ("to error message: " <> toErrorMessage filterStr e) (toErrorMessage filterStr e)
exitWith (ExitFailure 1)
Left (e:_) -> die $ toErrorMessage filterStr e
Left [] -> error "Wie ist es moglich"
Right filtered -> ioF filtered

Expand All @@ -86,9 +81,7 @@ applyFilterWithComparative dirname ioF filterStr = do
anchoredTree <- readDirectoryWith return dirname
filteredTreeE <- applyFilter dirname filterStr
case filteredTreeE of
Left (e:_) -> do
hPutStrLn stderr $ trace ("to error message: " <> toErrorMessage filterStr e) (toErrorMessage filterStr e)
exitWith (ExitFailure 1)
Left (e:_) -> die $ toErrorMessage filterStr e
Left [] -> error "Wie ist es moglich"
Right filtered -> ioF (toElements $ dirTree anchoredTree) filtered

Expand All @@ -97,9 +90,7 @@ applyFilterWithComparativeReproduce dirname ioF filterStr = do
anchoredTree <- readDirectoryWith return dirname
filteredTreeE <- applyFilter dirname filterStr
case filteredTreeE of
Left (e:_) -> do
hPutStrLn stderr $ trace ("to error message:\n" <> toErrorMessage filterStr e) (toErrorMessage filterStr e)
exitWith (ExitFailure 1)
Left (e:_) -> die $ toErrorMessage filterStr e
Left [] -> error "Wie ist es moglich"
Right filtered -> ioF (toElements $ dirTree anchoredTree) filtered

Expand Down
6 changes: 0 additions & 6 deletions src/call_err

This file was deleted.

Empty file removed src/call_out
Empty file.
1 change: 0 additions & 1 deletion src/result

This file was deleted.

2 changes: 1 addition & 1 deletion tree-surgeon-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

stdenv.mkDerivation {
name = "tstest";
src = tsLib.prune ./src/test/test-data ''endsWit ".cpp" (basename file)'';
src = tsLib.prune ./src/test/test-data "endsWith '.cpp' (basename file)";
dontUnpack = true;
buildPhase = ''
mkdir $out
Expand Down

0 comments on commit dcbb80d

Please sign in to comment.