when reading configs of local repos, first initializeSafe

This auto-generates a uuid if the local repo does not already have one.
This commit is contained in:
Joey Hess 2011-08-17 14:36:20 -04:00
parent cf33eff684
commit 32f27cc3e8
3 changed files with 34 additions and 25 deletions

17
Init.hs
View file

@ -5,7 +5,11 @@
- Licensed under the GNU GPL version 3 or higher.
-}
module Init (initialize, uninitialize) where
module Init (
initialize,
initializeSafe,
uninitialize
) where
import Control.Monad.State (liftIO)
import Control.Monad (unless)
@ -34,6 +38,17 @@ uninitialize = do
g <- Annex.gitRepo
gitPreCommitHookUnWrite g
{- Call to automatically initialize if there is already a git-annex
branch from somewhere. Otherwise, require a manual init
to avoid git-annex accidentially being run in git
repos that did not intend to use it. -}
initializeSafe :: Annex ()
initializeSafe = do
annexed <- Branch.hasSomeBranch
if annexed
then initialize
else error "First run: git-annex init"
{- set up a git pre-commit hook, if one is not already present -}
gitPreCommitHookWrite :: Git.Repo -> Annex ()
gitPreCommitHookWrite repo = do