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.

This commit is contained in:
Joey Hess 2013-04-22 15:36:34 -04:00
parent 8861e270be
commit 9cb223a8b3
6 changed files with 24 additions and 10 deletions

View file

@ -1,13 +1,13 @@
{- git-annex assistant environment {- git-annex environment
- -
- Copyright 2012 Joey Hess <joey@kitenet.net> - Copyright 2012 Joey Hess <joey@kitenet.net>
- -
- Licensed under the GNU GPL version 3 or higher. - 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 Utility.UserInfo
import qualified Git.Config import qualified Git.Config
@ -18,9 +18,14 @@ import System.Posix.Env
- environment variables. -} - environment variables. -}
checkEnvironment :: Annex () checkEnvironment :: Annex ()
checkEnvironment = do checkEnvironment = do
username <- liftIO myUserName
gecos <- liftIO myUserGecos
gitusername <- fromRepo $ Git.Config.getMaybe "user.name" 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 -- existing environment is not overwritten
liftIO $ setEnv "GIT_AUTHOR_NAME" username False setEnv "GIT_AUTHOR_NAME" username False
setEnv "GIT_COMMITTER_NAME" username False

View file

@ -154,7 +154,6 @@ import Assistant.Threads.XMPPClient
#warning Building without the webapp. You probably need to install Yesod.. #warning Building without the webapp. You probably need to install Yesod..
import Assistant.Types.UrlRenderer import Assistant.Types.UrlRenderer
#endif #endif
import Assistant.Environment
import qualified Utility.Daemon import qualified Utility.Daemon
import Utility.LogFile import Utility.LogFile
import Utility.ThreadScheduler import Utility.ThreadScheduler
@ -198,8 +197,6 @@ startDaemon assistant foreground listenhost startbrowser = do
| otherwise = "watch" | otherwise = "watch"
start daemonize webappwaiter = withThreadState $ \st -> do start daemonize webappwaiter = withThreadState $ \st -> do
checkCanWatch checkCanWatch
when assistant
checkEnvironment
dstatus <- startDaemonStatus dstatus <- startDaemonStatus
logfile <- fromRepo gitAnnexLogFile logfile <- fromRepo gitAnnexLogFile
liftIO $ debugM desc $ "logging to " ++ logfile liftIO $ debugM desc $ "logging to " ++ logfile

View file

@ -24,6 +24,7 @@ import qualified Git
import qualified Git.AutoCorrect import qualified Git.AutoCorrect
import Annex.Content import Annex.Content
import Annex.Ssh import Annex.Ssh
import Annex.Environment
import Command import Command
type Params = [String] type Params = [String]
@ -39,6 +40,7 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do
Right g -> do Right g -> do
state <- Annex.new g state <- Annex.new g
(actions, state') <- Annex.run state $ do (actions, state') <- Annex.run state $ do
checkEnvironment
checkfuzzy checkfuzzy
forM_ fields $ uncurry Annex.setField forM_ fields $ uncurry Annex.setField
sequence_ flags sequence_ flags

View file

@ -15,6 +15,7 @@ import Assistant.NamedThread
import Assistant.Threads.WebApp import Assistant.Threads.WebApp
import Assistant.WebApp import Assistant.WebApp
import Assistant.Install import Assistant.Install
import Annex.Environment
import Utility.WebApp import Utility.WebApp
import Utility.Daemon (checkDaemon) import Utility.Daemon (checkDaemon)
import Init import Init
@ -111,6 +112,7 @@ startNoRepo = do
-} -}
firstRun :: Maybe HostName -> IO () firstRun :: Maybe HostName -> IO ()
firstRun listenhost = do firstRun listenhost = do
checkEnvironmentIO
{- Without a repository, we cannot have an Annex monad, so cannot {- Without a repository, we cannot have an Annex monad, so cannot
- get a ThreadState. Using undefined is only safe because the - get a ThreadState. Using undefined is only safe because the
- webapp checks its noAnnex field before accessing the - webapp checks its noAnnex field before accessing the

4
debian/changelog vendored
View file

@ -9,6 +9,10 @@ git-annex (4.20130418) UNRELEASED; urgency=low
* sync, assistant: Sync with remotes that have annex-ignore set, * sync, assistant: Sync with remotes that have annex-ignore set,
so that git remotes on servers without git-annex installed can be used so that git remotes on servers without git-annex installed can be used
to keep clients' git repos in sync. 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 <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400 -- Joey Hess <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400

View file

@ -35,3 +35,7 @@ remote repository always fails**
> So, I'm going to repurpose this bug to track that problem. --[[Joey]] > 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"]] [[!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]]