log --before=date
This commit is contained in:
parent
539f8c6f14
commit
8e7de01047
3 changed files with 28 additions and 24 deletions
|
@ -24,6 +24,7 @@ import qualified Git
|
||||||
import Git.Command
|
import Git.Command
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
import qualified Option
|
import qualified Option
|
||||||
|
import qualified Annex
|
||||||
|
|
||||||
data RefChange = RefChange
|
data RefChange = RefChange
|
||||||
{ changetime :: POSIXTime
|
{ changetime :: POSIXTime
|
||||||
|
@ -32,29 +33,28 @@ data RefChange = RefChange
|
||||||
}
|
}
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions [afterOption, maxcountOption] $
|
def = [withOptions options $
|
||||||
command "log" paramPaths seek "shows location log"]
|
command "log" paramPaths seek "shows location log"]
|
||||||
|
|
||||||
afterOption :: Option
|
options :: [Option]
|
||||||
afterOption = Option.field [] "after" paramDate "show log after date"
|
options =
|
||||||
|
[ Option.field [] "after" paramDate "show log after date"
|
||||||
maxcountOption :: Option
|
, Option.field [] "before" paramDate "show log before date"
|
||||||
maxcountOption = Option.field ['n'] "max-count" paramNumber "limit number of logs displayed"
|
, Option.field ['n'] "max-count" paramNumber "limit number of logs displayed"
|
||||||
|
]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withField afterOption return $ \afteropt ->
|
seek = [withValue (concat <$> mapM getoption options) $ \os ->
|
||||||
withField maxcountOption return $ \maxcount ->
|
withFilesInGit $ whenAnnexed $ start os]
|
||||||
withFilesInGit $ whenAnnexed $ start afteropt maxcount]
|
|
||||||
|
|
||||||
start :: Maybe String -> Maybe String -> FilePath -> (Key, Backend) -> CommandStart
|
|
||||||
start afteropt maxcount file (key, _) = do
|
|
||||||
showLog file =<< readLog <$> getLog key ps
|
|
||||||
stop
|
|
||||||
where
|
where
|
||||||
ps = concatMap (\(o, p) -> maybe [] p o)
|
getoption o = maybe [] (use o) <$>
|
||||||
[ (afteropt, \d -> [Param "--after", Param d])
|
Annex.getField (Option.name o)
|
||||||
, (maxcount, \c -> [Param "--max-count", Param c])
|
use o v = [Param ("--" ++ Option.name o), Param v]
|
||||||
]
|
|
||||||
|
start :: [CommandParam] -> FilePath -> (Key, Backend) -> CommandStart
|
||||||
|
start os file (key, _) = do
|
||||||
|
showLog file =<< readLog <$> getLog key os
|
||||||
|
stop
|
||||||
|
|
||||||
showLog :: FilePath -> [RefChange] -> Annex ()
|
showLog :: FilePath -> [RefChange] -> Annex ()
|
||||||
showLog file ps = do
|
showLog file ps = do
|
||||||
|
@ -87,13 +87,13 @@ showLog file ps = do
|
||||||
[ addel, time, file, "|", r ]
|
[ addel, time, file, "|", r ]
|
||||||
|
|
||||||
getLog :: Key -> [CommandParam] -> Annex [String]
|
getLog :: Key -> [CommandParam] -> Annex [String]
|
||||||
getLog key ps = do
|
getLog key os = do
|
||||||
top <- fromRepo Git.workTree
|
top <- fromRepo Git.workTree
|
||||||
p <- liftIO $ relPathCwdToFile top
|
p <- liftIO $ relPathCwdToFile top
|
||||||
let logfile = p </> Logs.Location.logFile key
|
let logfile = p </> Logs.Location.logFile key
|
||||||
inRepo $ pipeNullSplit $
|
inRepo $ pipeNullSplit $
|
||||||
[ Params "log -z --pretty=format:%ct --raw --abbrev=40"
|
[ Params "log -z --pretty=format:%ct --raw --abbrev=40"
|
||||||
] ++ ps ++
|
] ++ os ++
|
||||||
[ Param $ show Annex.Branch.fullname
|
[ Param $ show Annex.Branch.fullname
|
||||||
, Param "--"
|
, Param "--"
|
||||||
, Param logfile
|
, Param logfile
|
||||||
|
|
10
Seek.hs
10
Seek.hs
|
@ -88,14 +88,18 @@ withKeys a params = return $ map (a . parse) params
|
||||||
where
|
where
|
||||||
parse p = fromMaybe (error "bad key") $ readKey p
|
parse p = fromMaybe (error "bad key") $ readKey p
|
||||||
|
|
||||||
|
withValue :: Annex v -> (v -> CommandSeek) -> CommandSeek
|
||||||
|
withValue v a params = do
|
||||||
|
r <- v
|
||||||
|
a r params
|
||||||
|
|
||||||
{- Modifies a seek action using the value of a field option, which is fed into
|
{- Modifies a seek action using the value of a field option, which is fed into
|
||||||
- a conversion function, and then is passed into the seek action.
|
- a conversion function, and then is passed into the seek action.
|
||||||
- This ensures that the conversion function only runs once.
|
- This ensures that the conversion function only runs once.
|
||||||
-}
|
-}
|
||||||
withField :: Option -> (Maybe String -> Annex a) -> (a -> CommandSeek) -> CommandSeek
|
withField :: Option -> (Maybe String -> Annex a) -> (a -> CommandSeek) -> CommandSeek
|
||||||
withField option converter a ps = do
|
withField option converter = withValue $
|
||||||
f <- converter =<< Annex.getField (Option.name option)
|
converter =<< Annex.getField (Option.name option)
|
||||||
a f ps
|
|
||||||
|
|
||||||
withNothing :: CommandStart -> CommandSeek
|
withNothing :: CommandStart -> CommandSeek
|
||||||
withNothing a [] = return [a]
|
withNothing a [] = return [a]
|
||||||
|
|
2
Usage.hs
2
Usage.hs
|
@ -73,7 +73,7 @@ paramUUID = "UUID"
|
||||||
paramType :: String
|
paramType :: String
|
||||||
paramType = "TYPE"
|
paramType = "TYPE"
|
||||||
paramDate :: String
|
paramDate :: String
|
||||||
paramDate = "Date"
|
paramDate = "DATE"
|
||||||
paramFormat :: String
|
paramFormat :: String
|
||||||
paramFormat = "FORMAT"
|
paramFormat = "FORMAT"
|
||||||
paramKeyValue :: String
|
paramKeyValue :: String
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue