2024-05-07 18:22:41 +00:00
|
|
|
{- git bundles
|
|
|
|
-
|
|
|
|
- Copyright 2024 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Git.Bundle where
|
|
|
|
|
|
|
|
import Common
|
|
|
|
import Git
|
|
|
|
import Git.Command
|
|
|
|
|
|
|
|
import Data.Char (ord)
|
|
|
|
import qualified Data.ByteString.Char8 as S8
|
|
|
|
|
|
|
|
listHeads :: FilePath -> Repo -> IO [(Sha, Ref)]
|
|
|
|
listHeads bundle repo = map gen . S8.lines <$>
|
|
|
|
pipeReadStrict [Param "bundle", Param "list-heads", File bundle] repo
|
|
|
|
where
|
|
|
|
gen l = let (s, r) = separate' (== fromIntegral (ord ' ')) l
|
|
|
|
in (Ref s, Ref r)
|
|
|
|
|
|
|
|
unbundle :: FilePath -> Repo -> IO ()
|
|
|
|
unbundle bundle = runQuiet [Param "bundle", Param "unbundle", File bundle]
|
2024-05-09 20:11:16 +00:00
|
|
|
|
|
|
|
create :: FilePath -> [Ref] -> Repo -> IO ()
|
|
|
|
create bundle refs repo = pipeWrite
|
|
|
|
[ Param "bundle"
|
|
|
|
, Param "create"
|
|
|
|
, Param "--quiet"
|
|
|
|
, File bundle
|
|
|
|
, Param "--stdin"
|
|
|
|
] repo writerefs
|
|
|
|
where
|
|
|
|
writerefs h = do
|
|
|
|
mapM_ (S8.hPutStrLn h . fromRef') refs
|
|
|
|
hClose h
|