mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
ba873cd46a
commit
dec9fbcc3d
|
@ -118,7 +118,8 @@ compression ; prints compression level
|
|||
r <- callRpcWaitRetry @RpcPoke (TimeoutSec 0.5) 2 peer () >>= orThrowUser "hbs2-peer not found"
|
||||
notice $ pretty r
|
||||
|
||||
entry $ bindMatch "test:git:hash:blob" $ nil_ $ const $ liftIO do
|
||||
hidden do
|
||||
entry $ bindMatch "git:hash:blob" $ nil_ $ const $ liftIO do
|
||||
co <- LBS.hGetContents stdin
|
||||
print $ pretty $ gitHashBlobPure co
|
||||
|
||||
|
@ -148,42 +149,6 @@ compression ; prints compression level
|
|||
for_ (HPSQ.toList r) $ \(k,_,_) -> do
|
||||
liftIO $ print $ pretty k
|
||||
|
||||
entry $ bindMatch "test:git:log:cat" $ nil_ $ \syn -> lift do
|
||||
|
||||
let (opts, argz) = splitOpts [("--git",0),("--packed",0),("--import",1)] syn
|
||||
|
||||
let git = or [ True | ListVal [StringLike "--git"] <- opts ]
|
||||
let packed = or [ True | ListVal [StringLike "--packed"] <- opts ]
|
||||
|
||||
(gh, fn) <- case argz of
|
||||
[ GitHashLike a, StringLike b ] -> do
|
||||
pure (a, b)
|
||||
|
||||
_ -> throwIO (BadFormException @C nil)
|
||||
|
||||
|
||||
src <- liftIO$ LBS.readFile fn
|
||||
|
||||
what <- S.toList_ $ runConsumeLBS (ZstdL.decompress src) $ readLogFileLBS () $ \h s src -> do
|
||||
let (t,rest) = LBS.splitAt 1 src
|
||||
|
||||
Short tp <- fromStringMay @(Short GitObjectType) (LBS8.unpack t)
|
||||
& orThrowUser "Invalid object type"
|
||||
|
||||
when ( h == gh ) $ lift $ S.yield (tp,rest)
|
||||
|
||||
liftIO $ maybe1 (listToMaybe what) (Q.exitFailure) $ \(t,s) -> do
|
||||
|
||||
let raw = if not git then s else do
|
||||
let signature = [qc|{pretty t} {pretty $ LBS.length s}|] <> "\x00" :: LBS8.ByteString
|
||||
signature <> s
|
||||
|
||||
let result = if not packed then raw else do
|
||||
let params = Zlib.defaultCompressParams { Zlib.compressMethod = Zlib.deflateMethod }
|
||||
Zlib.compressWith params raw
|
||||
|
||||
LBS.hPutStr stdout result
|
||||
|
||||
entry $ bindMatch "test:git:log:list" $ nil_ $ \syn -> do
|
||||
let (_, argz) = splitOpts [] syn
|
||||
|
||||
|
@ -194,7 +159,6 @@ compression ; prints compression level
|
|||
runConsumeLBS (ZstdL.decompress lbs) $ readLogFileLBS () $ \h s _ -> do
|
||||
liftIO $ print $ "object" <+> pretty h <+> pretty s
|
||||
|
||||
|
||||
entry $ bindMatch "test:reflog:index:search:binary:test:2" $ nil_ $ const $ lift do
|
||||
r <- newTQueueIO
|
||||
idx <- openIndex
|
||||
|
@ -306,7 +270,7 @@ compression ; prints compression level
|
|||
|
||||
liftIO $ hPrint stdout $ pretty sha1 <+> pretty blake
|
||||
|
||||
entry $ bindMatch "test:reflog:file:check" $ nil_ $ \case
|
||||
entry $ bindMatch "reflog:index:check" $ nil_ $ \case
|
||||
[ StringLike fn ] -> lift do
|
||||
bs <- liftIO $ mmapFileByteString fn Nothing
|
||||
|
||||
|
@ -470,11 +434,13 @@ compression ; prints compression level
|
|||
entry $ bindMatch "reflog:import" $ nil_ $ \syn -> lift $ connectedDo do
|
||||
importGitRefLog
|
||||
|
||||
entry $ bindMatch "repo:manifest:show" $ nil_ $ const $ lift $ connectedDo do
|
||||
brief "shows repo manifest" $
|
||||
entry $ bindMatch "repo:manifest" $ nil_ $ const $ lift $ connectedDo do
|
||||
manifest <- Repo.getRepoManifest
|
||||
liftIO $ print $ pretty $ mkForm "manifest" manifest
|
||||
|
||||
entry $ bindMatch "repo:reflog:show" $ nil_ $ const $ lift $ connectedDo do
|
||||
brief "shows repo reflog" $
|
||||
entry $ bindMatch "repo:reflog" $ nil_ $ const $ lift $ connectedDo do
|
||||
repo <- Repo.getRepoManifest
|
||||
|
||||
reflog <- [ x | x@(ListVal [SymbolVal "reflog", SignPubKeyLike _]) <- repo ]
|
||||
|
|
Loading…
Reference in New Issue