From 9cb223a8b3ef32bb976dd5a4b91e11fcb5e32890 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 22 Apr 2013 15:36:34 -0400 Subject: [PATCH] Detect systems that have no user name set in GECOS, and also don't have user.name set in git config, and put in a workaround so that commits to the git-annex branch (and the assistant) will still succeed despite git not liking the system configuration. --- {Assistant => Annex}/Environment.hs | 19 ++++++++++++------- Assistant.hs | 3 --- CmdLine.hs | 2 ++ Command/WebApp.hs | 2 ++ debian/changelog | 4 ++++ ...cond_remote_repository_over_ssh_fails.mdwn | 4 ++++ 6 files changed, 24 insertions(+), 10 deletions(-) rename {Assistant => Annex}/Environment.hs (58%) diff --git a/Assistant/Environment.hs b/Annex/Environment.hs similarity index 58% rename from Assistant/Environment.hs rename to Annex/Environment.hs index 3153fcfe55..357ad6958d 100644 --- a/Assistant/Environment.hs +++ b/Annex/Environment.hs @@ -1,13 +1,13 @@ -{- git-annex assistant environment +{- git-annex environment - - Copyright 2012 Joey Hess - - Licensed under the GNU GPL version 3 or higher. -} -module Assistant.Environment where +module Annex.Environment where -import Assistant.Common +import Common.Annex import Utility.UserInfo import qualified Git.Config @@ -18,9 +18,14 @@ import System.Posix.Env - 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 "")) $ + when (gitusername == Nothing || gitusername == Just "") $ + liftIO checkEnvironmentIO + +checkEnvironmentIO :: IO () +checkEnvironmentIO = do + whenM (null <$> myUserGecos) $ do + username <- myUserName -- existing environment is not overwritten - liftIO $ setEnv "GIT_AUTHOR_NAME" username False + setEnv "GIT_AUTHOR_NAME" username False + setEnv "GIT_COMMITTER_NAME" username False diff --git a/Assistant.hs b/Assistant.hs index 92cc275b54..e246145171 100644 --- a/Assistant.hs +++ b/Assistant.hs @@ -154,7 +154,6 @@ import Assistant.Threads.XMPPClient #warning Building without the webapp. You probably need to install Yesod.. import Assistant.Types.UrlRenderer #endif -import Assistant.Environment import qualified Utility.Daemon import Utility.LogFile import Utility.ThreadScheduler @@ -198,8 +197,6 @@ startDaemon assistant foreground listenhost startbrowser = do | otherwise = "watch" start daemonize webappwaiter = withThreadState $ \st -> do checkCanWatch - when assistant - checkEnvironment dstatus <- startDaemonStatus logfile <- fromRepo gitAnnexLogFile liftIO $ debugM desc $ "logging to " ++ logfile diff --git a/CmdLine.hs b/CmdLine.hs index 63d36c74ce..050f119f14 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -24,6 +24,7 @@ import qualified Git import qualified Git.AutoCorrect import Annex.Content import Annex.Ssh +import Annex.Environment import Command type Params = [String] @@ -39,6 +40,7 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do Right g -> do state <- Annex.new g (actions, state') <- Annex.run state $ do + checkEnvironment checkfuzzy forM_ fields $ uncurry Annex.setField sequence_ flags diff --git a/Command/WebApp.hs b/Command/WebApp.hs index 90abd4d276..0e07569015 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -15,6 +15,7 @@ import Assistant.NamedThread import Assistant.Threads.WebApp import Assistant.WebApp import Assistant.Install +import Annex.Environment import Utility.WebApp import Utility.Daemon (checkDaemon) import Init @@ -111,6 +112,7 @@ startNoRepo = do -} firstRun :: Maybe HostName -> IO () firstRun listenhost = do + checkEnvironmentIO {- Without a repository, we cannot have an Annex monad, so cannot - get a ThreadState. Using undefined is only safe because the - webapp checks its noAnnex field before accessing the diff --git a/debian/changelog b/debian/changelog index 86500c6f8a..c0cba45ceb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,10 @@ git-annex (4.20130418) UNRELEASED; urgency=low * sync, assistant: Sync with remotes that have annex-ignore set, so that git remotes on servers without git-annex installed can be used to keep clients' git repos in sync. + * Detect systems that have no user name set in GECOS, and also + don't have user.name set in git config, and put in a workaround + so that commits to the git-annex branch (and the assistant) + will still succeed despite git not liking the system configuration. -- Joey Hess Thu, 18 Apr 2013 16:22:48 -0400 diff --git a/doc/bugs/Adding_second_remote_repository_over_ssh_fails.mdwn b/doc/bugs/Adding_second_remote_repository_over_ssh_fails.mdwn index 7b449f4215..abb5226bed 100644 --- a/doc/bugs/Adding_second_remote_repository_over_ssh_fails.mdwn +++ b/doc/bugs/Adding_second_remote_repository_over_ssh_fails.mdwn @@ -35,3 +35,7 @@ remote repository always fails** > So, I'm going to repurpose this bug to track that problem. --[[Joey]] [[!meta title="assistant can fail to make git repository if remote server is lacking GECOS"]] + +>> [[done]]; git-annex always checks for missing gecos and enables +>> a workaround. This does mean the server needs to be upgraded in order +>> for the fix to work. --[[Joey]]