2016-05-04 13:44:06 +02:00
|
|
|
{- This file is part of Vervis.
|
|
|
|
-
|
|
|
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
|
|
|
-
|
|
|
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
|
|
|
-
|
|
|
|
- The author(s) have dedicated all copyright and related and neighboring
|
|
|
|
- rights to this software to the public domain worldwide. This software is
|
|
|
|
- distributed without any warranty.
|
|
|
|
-
|
|
|
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
|
|
|
- with this software. If not, see
|
|
|
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Darcs.Local
|
2016-05-04 19:17:47 +02:00
|
|
|
( createRepo
|
2016-05-04 13:44:06 +02:00
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
import Prelude
|
|
|
|
|
|
|
|
import System.Directory (createDirectory)
|
|
|
|
import System.Exit (ExitCode (..))
|
|
|
|
import System.FilePath ((</>))
|
|
|
|
import System.Process (createProcess, proc, waitForProcess)
|
|
|
|
|
|
|
|
{-
|
|
|
|
initialRepoTree :: FileName -> DirTree B.ByteString
|
|
|
|
initialRepoTree repo =
|
|
|
|
Dir repo
|
|
|
|
[ Dir "_darcs"
|
|
|
|
--[ File "format"
|
|
|
|
-- "hashed|no-working-dir\n\
|
|
|
|
-- \darcs-2"
|
|
|
|
--, File "hashed_inventory" ""
|
|
|
|
--, File "index" ???
|
|
|
|
, Dir "inventories" []
|
|
|
|
, Dir "patches" []
|
|
|
|
, Dir "prefs" []
|
|
|
|
-- [ File "binaries" ""
|
|
|
|
-- , File "boring" ""
|
|
|
|
-- , File "motd" ""
|
|
|
|
-- ]
|
|
|
|
, Dir "pristine.hashed" []
|
|
|
|
]
|
|
|
|
]
|
|
|
|
-}
|
|
|
|
|
|
|
|
-- | initialize a new bare repository at a specific location.
|
2016-05-04 19:17:47 +02:00
|
|
|
createRepo
|
2016-05-04 13:44:06 +02:00
|
|
|
:: FilePath
|
|
|
|
-- ^ Parent directory which already exists
|
|
|
|
-> String
|
|
|
|
-- ^ Name of new repo, i.e. new directory to create under the parent
|
|
|
|
-> IO ()
|
2016-05-04 19:17:47 +02:00
|
|
|
createRepo parent name = do
|
2016-05-04 13:44:06 +02:00
|
|
|
let path = parent </> name
|
|
|
|
createDirectory path
|
|
|
|
let settings = proc "darcs" ["init", "--no-working-dir", path]
|
|
|
|
(_, _, _, ph) <- createProcess settings
|
|
|
|
ec <- waitForProcess ph
|
|
|
|
case ec of
|
|
|
|
ExitSuccess -> return ()
|
|
|
|
ExitFailure n -> error $ "darcs init failed with exit code " ++ show n
|