2013-04-22 19:36:34 +00:00
|
|
|
{- git-annex environment
|
2013-01-06 17:34:08 +00:00
|
|
|
-
|
|
|
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
2013-04-22 19:36:34 +00:00
|
|
|
module Annex.Environment where
|
2013-01-06 17:34:08 +00:00
|
|
|
|
2013-04-22 19:36:34 +00:00
|
|
|
import Common.Annex
|
2013-01-06 17:34:08 +00:00
|
|
|
import Utility.UserInfo
|
|
|
|
import qualified Git.Config
|
|
|
|
|
|
|
|
import System.Posix.Env
|
|
|
|
|
|
|
|
{- Checks that the system's environment allows git to function.
|
|
|
|
- Git requires a GECOS username, or suitable git configuration, or
|
|
|
|
- environment variables. -}
|
|
|
|
checkEnvironment :: Annex ()
|
|
|
|
checkEnvironment = do
|
|
|
|
gitusername <- fromRepo $ Git.Config.getMaybe "user.name"
|
2013-04-22 19:36:34 +00:00
|
|
|
when (gitusername == Nothing || gitusername == Just "") $
|
|
|
|
liftIO checkEnvironmentIO
|
|
|
|
|
|
|
|
checkEnvironmentIO :: IO ()
|
|
|
|
checkEnvironmentIO = do
|
|
|
|
whenM (null <$> myUserGecos) $ do
|
|
|
|
username <- myUserName
|
2013-01-06 17:34:08 +00:00
|
|
|
-- existing environment is not overwritten
|
2013-04-22 19:36:34 +00:00
|
|
|
setEnv "GIT_AUTHOR_NAME" username False
|
|
|
|
setEnv "GIT_COMMITTER_NAME" username False
|