assistant: Detect when system is not configured with a user name, and set environment to prevent git from failing.
This commit is contained in:
parent
24df1f6ee0
commit
13d2fffb2d
4 changed files with 35 additions and 1 deletions
26
Assistant/Environment.hs
Normal file
26
Assistant/Environment.hs
Normal file
|
@ -0,0 +1,26 @@
|
|||
{- git-annex assistant environment
|
||||
-
|
||||
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Assistant.Environment where
|
||||
|
||||
import Assistant.Common
|
||||
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
|
||||
username <- liftIO myUserName
|
||||
gecos <- liftIO myUserGecos
|
||||
gitusername <- fromRepo $ Git.Config.getMaybe "user.name"
|
||||
when (null gecos && (gitusername == Nothing || gitusername == Just "")) $
|
||||
-- existing environment is not overwritten
|
||||
liftIO $ setEnv "GIT_AUTHOR_NAME" username False
|
Loading…
Add table
Add a link
Reference in a new issue