importfeed: git-annex becomes a podcatcher in 150 LOC

This commit is contained in:
Joey Hess 2013-07-28 15:27:36 -04:00
parent 55bd5a81ad
commit 7e66d260ea
15 changed files with 319 additions and 32 deletions

View file

@ -12,6 +12,7 @@ module Git.LsFiles (
modified,
staged,
stagedNotDeleted,
stagedOthersDetails,
stagedDetails,
typeChanged,
typeChangedStaged,
@ -69,16 +70,24 @@ staged' ps l = pipeNullSplit $ prefix ++ ps ++ suffix
prefix = [Params "diff --cached --name-only -z"]
suffix = Param "--" : map File l
{- Returns details about files that are staged in the index
- (including the Sha of their staged contents),
- as well as files not yet in git. -}
{- Returns details about files that are staged in the index,
- as well as files not yet in git. Skips ignored files. -}
stagedOthersDetails :: [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha)], IO Bool)
stagedOthersDetails = stagedDetails' [Params "--others --exclude-standard"]
{- Returns details about all files that are staged in the index. -}
stagedDetails :: [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha)], IO Bool)
stagedDetails l repo = do
stagedDetails = stagedDetails' []
{- Gets details about staged files, including the Sha of their staged
- contents. -}
stagedDetails' :: [CommandParam] -> [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha)], IO Bool)
stagedDetails' ps l repo = do
(ls, cleanup) <- pipeNullSplit params repo
return (map parse ls, cleanup)
where
params = [Params "ls-files --others --exclude-standard --stage -z --"] ++
map File l
params = Params "ls-files --stage -z" : ps ++
Param "--" : map File l
parse s
| null file = (s, Nothing)
| otherwise = (file, extractSha $ take shaSize $ drop 7 metadata)