add typeChangedFiles
This commit is contained in:
parent
d0886a9ac7
commit
81524d19a7
1 changed files with 17 additions and 4 deletions
21
GitRepo.hs
21
GitRepo.hs
|
@ -39,6 +39,7 @@ module GitRepo (
|
||||||
checkAttr,
|
checkAttr,
|
||||||
decodeGitFile,
|
decodeGitFile,
|
||||||
encodeGitFile,
|
encodeGitFile,
|
||||||
|
typeChangedFiles,
|
||||||
|
|
||||||
prop_idempotent_deencode
|
prop_idempotent_deencode
|
||||||
) where
|
) where
|
||||||
|
@ -58,6 +59,7 @@ import Data.Char
|
||||||
import Data.Word (Word8)
|
import Data.Word (Word8)
|
||||||
import Codec.Binary.UTF8.String (encode)
|
import Codec.Binary.UTF8.String (encode)
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
|
import Data.List
|
||||||
|
|
||||||
import Utility
|
import Utility
|
||||||
|
|
||||||
|
@ -227,20 +229,31 @@ hPipeRead repo params = assertLocal repo $ do
|
||||||
- are checked into git at that location. -}
|
- are checked into git at that location. -}
|
||||||
inRepo :: Repo -> FilePath -> IO [FilePath]
|
inRepo :: Repo -> FilePath -> IO [FilePath]
|
||||||
inRepo repo l = pipeNullSplit repo
|
inRepo repo l = pipeNullSplit repo
|
||||||
["ls-files", "--cached", "--exclude-standard", "-z", l]
|
["ls-files", "--cached", "--exclude-standard", "-z", "--", l]
|
||||||
|
|
||||||
{- Passed a location, recursively scans for all files that are not checked
|
{- Passed a location, recursively scans for all files that are not checked
|
||||||
- into git, and not gitignored. -}
|
- into git, and not gitignored. -}
|
||||||
notInRepo :: Repo -> FilePath -> IO [FilePath]
|
notInRepo :: Repo -> FilePath -> IO [FilePath]
|
||||||
notInRepo repo l = pipeNullSplit repo
|
notInRepo repo l = pipeNullSplit repo
|
||||||
["ls-files", "--others", "--exclude-standard", "-z", l]
|
["ls-files", "--others", "--exclude-standard", "-z", "--", l]
|
||||||
|
|
||||||
{- Passed a location, returns a list of the files, staged for
|
{- Passed a location, returns a list of the files, staged for
|
||||||
- commit, that are being added, moved, or changed (but not deleted). -}
|
- commit, that are being added, moved, or changed (but not deleted). -}
|
||||||
stagedFiles :: Repo -> FilePath -> IO [FilePath]
|
stagedFiles :: Repo -> FilePath -> IO [FilePath]
|
||||||
stagedFiles repo l = pipeNullSplit repo
|
stagedFiles repo l = pipeNullSplit repo
|
||||||
["diff", "--cached", "--name-only", "--diff-filter=ACMRT", "-z",
|
["diff", "--cached", "--name-only", "--diff-filter=ACMRT", "-z",
|
||||||
"HEAD", l]
|
"--", l]
|
||||||
|
|
||||||
|
{- Passed a location, returns a list of the files whose type has changed. -}
|
||||||
|
typeChangedFiles :: Repo -> FilePath -> IO [FilePath]
|
||||||
|
typeChangedFiles repo l = do
|
||||||
|
changed <- pipeNullSplit repo $ start ++ end
|
||||||
|
changedCached <- pipeNullSplit repo $ start ++ ["--cached"] ++ end
|
||||||
|
-- a file can be found twice by the above, so nub
|
||||||
|
return $ nub $ changed ++ changedCached
|
||||||
|
where
|
||||||
|
start = ["diff", "--name-only", "--diff-filter=T", "-z"]
|
||||||
|
end = ["--", l]
|
||||||
|
|
||||||
{- Reads null terminated output of a git command (as enabled by the -z
|
{- Reads null terminated output of a git command (as enabled by the -z
|
||||||
- parameter), and splits it into a list of files. -}
|
- parameter), and splits it into a list of files. -}
|
||||||
|
|
Loading…
Reference in a new issue