update
This commit is contained in:
parent
ea5d7fe07a
commit
dc1d5e6831
3 changed files with 39 additions and 47 deletions
36
UUID.hs
Normal file
36
UUID.hs
Normal file
|
@ -0,0 +1,36 @@
|
|||
{- git-annex uuids
|
||||
-
|
||||
- Each git repository used by git-annex has an annex.uuid setting that
|
||||
- uniquely identifies that repository.
|
||||
-
|
||||
-}
|
||||
|
||||
module UUID (
|
||||
getUUID,
|
||||
prepUUID,
|
||||
genUUID
|
||||
) where
|
||||
|
||||
import System.Cmd.Utils
|
||||
import System.IO
|
||||
import GitRepo
|
||||
|
||||
configkey="annex.uuid"
|
||||
|
||||
{- Generates a UUID. There is a library for this, but it's not packaged,
|
||||
- so use the command line tool. -}
|
||||
genUUID :: IO String
|
||||
genUUID = do
|
||||
pOpen ReadFromPipe "uuid" ["-m"] $ \h -> hGetLine h
|
||||
|
||||
getUUID :: GitRepo -> String
|
||||
getUUID repo = gitConfig repo "annex.uuid" ""
|
||||
|
||||
{- Make sure that the repo has an annex.uuid setting. -}
|
||||
prepUUID :: GitRepo -> IO ()
|
||||
prepUUID repo =
|
||||
if ("" == getUUID repo)
|
||||
then do
|
||||
uuid <- genUUID
|
||||
gitRun repo ["config", configkey, uuid]
|
||||
else return ()
|
Loading…
Add table
Add a link
Reference in a new issue