From 7099603df6747e179e38b31738a5c5280ebdb46d Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 5 Apr 2017 17:52:51 -0700 Subject: [PATCH 1/3] Only write trailing newline for json output --- src/SemanticDiff.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SemanticDiff.hs b/src/SemanticDiff.hs index 7db2a6a8a..5b01dd1f9 100644 --- a/src/SemanticDiff.hs +++ b/src/SemanticDiff.hs @@ -48,10 +48,10 @@ main = do R.Index -> parseIndex args R.SExpression -> parseSExpression args _ -> parseTree args - writeToOutput outputPath (text <> "\n") + writeToOutput outputPath text where encodeText = encodeUtf8 . R.unFile - encodeJSON = toS . encode - encodeSummaries = toS . encode + encodeJSON = toS . (<> "\n") . encode + encodeSummaries = toS . (<> "\n") . encode -- | A parser for the application's command-line arguments. argumentsParser :: ParserInfo CmdLineOptions From 3c596fb9801340a7ee4e5b3b276d99c05d582ef7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 7 Apr 2017 10:47:56 -0400 Subject: [PATCH 2/3] Take the difference on full blob entries, not just their paths. --- src/Command.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Command.hs b/src/Command.hs index c928d5c0d..85f2976c9 100644 --- a/src/Command.hs +++ b/src/Command.hs @@ -138,9 +138,9 @@ runReadFilesAtSHAs :: FilePath -> [FilePath] -> [FilePath] -> Both String -> IO runReadFilesAtSHAs gitDir alternateObjectDirs paths shas = do paths <- case paths of [] -> runGit $ do - trees <- traverse treeForSha shas - paths <- traverse pathsForTree trees - pure $! runBothWith (\\) paths <> runBothWith (flip (\\)) paths + trees <- for shas treeForSha + paths <- for trees (reportGitmon "ls-tree" . treeBlobEntries) + pure $! (\ (p, _, _) -> toS p) <$> runBothWith (\\) paths <> runBothWith (flip (\\)) paths _ -> pure paths Async.withTaskGroup numCapabilities (\ group -> Async.runTask group (traverse (Async.task . runGit . blobsForPath) paths)) @@ -158,9 +158,6 @@ runReadFilesAtSHAs gitDir alternateObjectDirs paths shas = do let oid = renderObjOid $ blobOid blob pure (Just (SourceBlob transcoded (toS oid) path (Just (toSourceKind entryKind)))) _ -> pure Nothing - pathsForTree tree = do - blobEntries <- reportGitmon "ls-tree" $ treeBlobEntries tree - return $! fmap (\ (p, _, _) -> toS p) blobEntries runGit :: ReaderT LgRepo IO a -> IO a runGit action = withRepository lgFactory gitDir $ do From 2d0b3ff4b12beafe21a56f1866faebf9777c2a00 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 7 Apr 2017 10:49:36 -0400 Subject: [PATCH 3/3] Unique the list of paths. --- src/Command.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Command.hs b/src/Command.hs index 85f2976c9..6f2b2d880 100644 --- a/src/Command.hs +++ b/src/Command.hs @@ -22,7 +22,7 @@ import Control.Monad.IO.Class import Control.Parallel.Strategies import qualified Data.ByteString as B import Data.Functor.Both -import Data.List ((\\)) +import Data.List ((\\), nub) import Data.RandomWalkSimilarity import Data.Record import Data.String @@ -140,7 +140,7 @@ runReadFilesAtSHAs gitDir alternateObjectDirs paths shas = do [] -> runGit $ do trees <- for shas treeForSha paths <- for trees (reportGitmon "ls-tree" . treeBlobEntries) - pure $! (\ (p, _, _) -> toS p) <$> runBothWith (\\) paths <> runBothWith (flip (\\)) paths + pure . nub $! (\ (p, _, _) -> toS p) <$> runBothWith (\\) paths <> runBothWith (flip (\\)) paths _ -> pure paths Async.withTaskGroup numCapabilities (\ group -> Async.runTask group (traverse (Async.task . runGit . blobsForPath) paths))