import: Support file matching options such as --exclude, --include, --smallerthan, --largerthan

This commit is contained in:
Joey Hess 2015-02-06 15:58:06 -04:00
parent 9723333d86
commit dfab5e6ff4
3 changed files with 16 additions and 3 deletions

View file

@ -66,14 +66,20 @@ withFilesInRefs a = mapM_ go
void $ commandAction $ a f k void $ commandAction $ a f k
withPathContents :: ((FilePath, FilePath) -> CommandStart) -> CommandSeek withPathContents :: ((FilePath, FilePath) -> CommandStart) -> CommandSeek
withPathContents a params = seekActions $ withPathContents a params = do
map a . concat <$> liftIO (mapM get params) matcher <- Limit.getMatcher
seekActions $ map a <$> (filterM (checkmatch matcher) =<< ps)
where where
ps = concat <$> liftIO (mapM get params)
get p = ifM (isDirectory <$> getFileStatus p) get p = ifM (isDirectory <$> getFileStatus p)
( map (\f -> (f, makeRelative (parentDir p) f)) ( map (\f -> (f, makeRelative (parentDir p) f))
<$> dirContentsRecursiveSkipping (".git" `isSuffixOf`) True p <$> dirContentsRecursiveSkipping (".git" `isSuffixOf`) True p
, return [(p, takeFileName p)] , return [(p, takeFileName p)]
) )
checkmatch matcher (f, relf) = matcher $ MatchingFile $ FileInfo
{ relFile = f
, matchFile = relf
}
withWords :: ([String] -> CommandStart) -> CommandSeek withWords :: ([String] -> CommandStart) -> CommandSeek
withWords a params = seekActions $ return [a params] withWords a params = seekActions $ return [a params]

2
debian/changelog vendored
View file

@ -6,6 +6,8 @@ git-annex (5.20150206) UNRELEASED; urgency=medium
parameters it does not understand. parameters it does not understand.
* groupwanted: New command to set the groupwanted preferred content * groupwanted: New command to set the groupwanted preferred content
expression. expression.
* import: Support file matching options such as --exclude, --include,
--smallerthan, --largerthan
-- Joey Hess <id@joeyh.name> Fri, 06 Feb 2015 13:57:08 -0400 -- Joey Hess <id@joeyh.name> Fri, 06 Feb 2015 13:57:08 -0400

View file

@ -272,6 +272,11 @@ subdirectories).
(Note that using `--deduplicate` or `--clean-duplicates` with the WORM (Note that using `--deduplicate` or `--clean-duplicates` with the WORM
backend does not look at file content, but filename and mtime.) backend does not look at file content, but filename and mtime.)
To control which files are imported, many of the MATCHING OPTIONS can
be used.
git annex import /dir --include='*.png'
* `importfeed [url ...]` * `importfeed [url ...]`
@ -724,7 +729,7 @@ subdirectories).
When no item is specified, displays statistics and information When no item is specified, displays statistics and information
for the repository as a whole. for the repository as a whole.
When a directory is specified, the file matching options can be used When a directory is specified, the MATCHING OPTIONS can be used
to select the files in the directory that are included in the statistics. to select the files in the directory that are included in the statistics.
To only show the data that can be gathered quickly, use `--fast`. To only show the data that can be gathered quickly, use `--fast`.