aboutsummaryrefslogtreecommitdiff
path: root/Annex/Environment.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-06-08 15:04:15 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-06-08 15:04:15 -0400
commita5681bf82cb2f43c4615529fb5eca3dd1f15268a (patch)
treed49ef2805c93f144f283e5d8209b44e0bb03ad65 /Annex/Environment.hs
parentcb25507c65962391a5061c1915541008d930df46 (diff)
also avoid crashing in most circumstances if unable to determine the username
Mostly the username is only used for the git committer or other display purposes, and we can just fall back to a dummy value in these cases. The only remaining place where an error is thrown is when starting local pairing, which needs the username to be known.
Diffstat (limited to 'Annex/Environment.hs')
-rw-r--r--Annex/Environment.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/Annex/Environment.hs b/Annex/Environment.hs
index a066e9ab0..4f0fda986 100644
--- a/Annex/Environment.hs
+++ b/Annex/Environment.hs
@@ -33,7 +33,7 @@ checkEnvironment = do
checkEnvironmentIO :: IO ()
checkEnvironmentIO = whenM (isNothing <$> myUserGecos) $ do
- username <- myUserName
+ username <- either (const "unknown") id <$> myUserName
ensureEnv "GIT_AUTHOR_NAME" username
ensureEnv "GIT_COMMITTER_NAME" username
where
@@ -52,7 +52,7 @@ ensureCommit :: Annex a -> Annex a
ensureCommit a = either retry return =<< tryNonAsync a
where
retry _ = do
- name <- liftIO myUserName
+ name <- liftIO $ either (const "unknown") id <$> myUserName
setConfig (ConfigKey "user.name") name
setConfig (ConfigKey "user.email") name
a