1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Abstract out running a git command with alternate object dirs.

This commit is contained in:
Rob Rix 2017-04-05 09:38:18 -04:00
parent 5f1f82fb33
commit c9175254e7

View File

@ -136,10 +136,7 @@ runReadFile path = do
return (flip sourceBlob path <$> source)
runReadFilesAtSHAs :: FilePath -> [FilePath] -> [FilePath] -> Both String -> IO [(FilePath, Both (Maybe SourceBlob))]
runReadFilesAtSHAs gitDir alternateObjectDirs paths shas = withRepository lgFactory gitDir $ do
repo <- getRepository
for_ alternateObjectDirs (liftIO . odbBackendAddPath repo . toS)
runReadFilesAtSHAs gitDir alternateObjectDirs paths shas = runGit $ do
liftIO $ traceEventIO ("START readFilesAtSHAs: " <> show paths)
trees <- traverse treeForSha shas
@ -172,6 +169,11 @@ runReadFilesAtSHAs gitDir alternateObjectDirs paths shas = withRepository lgFact
blobEntries <- reportGitmon "ls-tree" $ treeBlobEntries tree
return $! fmap (\ (p, _, _) -> toS p) blobEntries
runGit action = withRepository lgFactory gitDir $ do
repo <- getRepository
for_ alternateObjectDirs (liftIO . odbBackendAddPath repo . toS)
action
toSourceKind (Git.PlainBlob mode) = Source.PlainBlob mode
toSourceKind (Git.ExecutableBlob mode) = Source.ExecutableBlob mode
toSourceKind (Git.SymlinkBlob mode) = Source.SymlinkBlob mode