summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-01-06 13:34:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-01-06 13:34:08 -0400
commitd4c642e989ab10e476757dbdc48c0d5dd6b3bb8b (patch)
treeb899309115f7e6d25af4ca941b0d4570a0f986d0 /Assistant
parentf410b244d87cc1b2f9aa832253ee8704e369eb7f (diff)
assistant: Detect when system is not configured with a user name, and set environment to prevent git from failing.
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Environment.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Assistant/Environment.hs b/Assistant/Environment.hs
new file mode 100644
index 000000000..3153fcfe5
--- /dev/null
+++ b/Assistant/Environment.hs
@@ -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