aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Fabian Kirchner <kirchner@posteo.de>2023-10-14 16:23:29 +0200
committerLibravatar Fabian Kirchner <kirchner@posteo.de>2023-10-14 16:23:29 +0200
commitede0a0761858e41b042d4c107c6f667b228df137 (patch)
tree0273c9333ac86beba2e871f2947b87459d6fd267
parent053fb659df51d8f60cc0aa283608cd1dca3764d0 (diff)
add getIssuesCommitAll
-rw-r--r--app/History.hs49
1 files changed, 32 insertions, 17 deletions
diff --git a/app/History.hs b/app/History.hs
index f1d3e97..a3cdf75 100644
--- a/app/History.hs
+++ b/app/History.hs
@@ -64,22 +64,21 @@ merge (issue, issues) =
getIssuesWorkingTreeAll :: [FilePath] -> IO [Issue]
getIssuesWorkingTreeAll paths = do
cwd <- getCurrentDirectory
- files <- getFiles cwd paths
+ files <- getFilesAllIn cwd paths
concat <$> catch (getIssuesPar cwd files) dieOfInvalidTreeGrepperResult
-getFiles :: FilePath -> [String] -> IO [FilePath]
-getFiles cwd paths =
- Prelude.lines . L8.unpack
- <$> sh
- ( fromString
- ( (printf "git ls-files --cached --exclude-standard --other%s")
- ( case paths of
- [] -> ""
- _ -> " -- " ++ intercalate " " (map quote paths)
- )
- )
- & setWorkingDir cwd
- )
+-- | Given the hash of a commit, get all issues in all files at the
+-- [tree](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddeftreeatree)
+-- of this commit.
+getIssuesCommitAll :: Text -> IO [Issue]
+getIssuesCommitAll hash = do
+ withSystemTempDirectory "history" $ \tmp -> do
+ cwd <- do
+ let cwd = tmp </> unpack hash
+ sh_ $ fromString $ printf "git worktree add --detach %s %s" (quote cwd) (quote $ unpack hash)
+ pure cwd
+ files <- getFilesAll cwd
+ concat <$> catch (getIssuesPar cwd files) (dieOfInvalidTreeGrepperResult)
-- | Given the hash of a commit, get all issues in the files which have
-- been changed by this commit.
@@ -93,14 +92,30 @@ getIssuesCommitChanged hash = do
files <- getFilesChanged cwd
concat <$> catch (getIssuesPar cwd files) (dieOfInvalidTreeGrepperResult)
-getFilesChanged :: FilePath -> IO [FilePath]
-getFilesChanged cwd =
+getFilesAll :: FilePath -> IO [FilePath]
+getFilesAll cwd =
+ Prelude.lines . L8.unpack
+ <$> sh ("git ls-files --cached --exclude-standard --other" & setWorkingDir cwd)
+
+getFilesAllIn :: FilePath -> [String] -> IO [FilePath]
+getFilesAllIn cwd paths =
Prelude.lines . L8.unpack
<$> sh
- ( "git show -p --name-only --format=''"
+ ( fromString
+ ( (printf "git ls-files --cached --exclude-standard --other%s")
+ ( case paths of
+ [] -> ""
+ _ -> " -- " ++ intercalate " " (map quote paths)
+ )
+ )
& setWorkingDir cwd
)
+getFilesChanged :: FilePath -> IO [FilePath]
+getFilesChanged cwd =
+ Prelude.lines . L8.unpack
+ <$> sh ("git show -p --name-only --format=''" & setWorkingDir cwd)
+
-- | Get all issues in the given directory and files. Runs
-- parallelized.
getIssuesPar :: FilePath -> [FilePath] -> IO [[Issue]]