detect system with no dot in FQDN, where git commit will fail, and workaround

Sigh, git is so *fragile*. Or rather, across the set of systems that use
git-annex, where are no many horribly broken systems..
This commit is contained in:
Joey Hess 2013-07-05 12:24:28 -04:00
parent 62f391480d
commit d84a000e92
5 changed files with 37 additions and 7 deletions

View file

@ -13,10 +13,19 @@ import Common.Annex
import Utility.Env import Utility.Env
import Utility.UserInfo import Utility.UserInfo
import qualified Git.Config import qualified Git.Config
import Config
import Annex.Exception
{- Checks that the system's environment allows git to function. {- Checks that the system's environment allows git to function.
- Git requires a GECOS username, or suitable git configuration, or - Git requires a GECOS username, or suitable git configuration, or
- environment variables. -} - environment variables.
-
- Git also requires the system have a hostname containing a dot.
- Otherwise, it tries various methods to find a FQDN, and will fail if it
- does not. To avoid replicating that code here, which would break if its
- methods change, this function does not check the hostname is valid.
- Instead, code that commits can use ensureCommit.
-}
checkEnvironment :: Annex () checkEnvironment :: Annex ()
checkEnvironment = do checkEnvironment = do
gitusername <- fromRepo $ Git.Config.getMaybe "user.name" gitusername <- fromRepo $ Git.Config.getMaybe "user.name"
@ -42,3 +51,12 @@ checkEnvironmentIO =
ensureEnv _ _ = noop ensureEnv _ _ = noop
#endif #endif
#endif #endif
{- Runs an action that commits to the repository, and if it fails,
- sets user.email to a dummy value and tries the action again. -}
ensureCommit :: Annex a -> Annex a
ensureCommit a = either retry return =<< tryAnnex a
where
retry _ = do
setConfig (ConfigKey "user.email") =<< liftIO myUserName
a

View file

@ -366,9 +366,7 @@ inDir dir a = do
{- Creates a new repository, and returns its UUID. -} {- Creates a new repository, and returns its UUID. -}
initRepo :: Bool -> Bool -> FilePath -> Maybe String -> IO UUID initRepo :: Bool -> Bool -> FilePath -> Maybe String -> IO UUID
initRepo True primary_assistant_repo dir desc = inDir dir $ do initRepo True primary_assistant_repo dir desc = inDir dir $ do
{- Initialize a git-annex repository in a directory with a description. -} initRepo' desc
unlessM isInitialized $
initialize desc
{- Initialize the master branch, so things that expect {- Initialize the master branch, so things that expect
- to have it will work, before any files are added. -} - to have it will work, before any files are added. -}
unlessM (Git.Config.isBare <$> gitRepo) $ unlessM (Git.Config.isBare <$> gitRepo) $
@ -391,9 +389,13 @@ initRepo True primary_assistant_repo dir desc = inDir dir $ do
getUUID getUUID
{- Repo already exists, could be a non-git-annex repo though. -} {- Repo already exists, could be a non-git-annex repo though. -}
initRepo False _ dir desc = inDir dir $ do initRepo False _ dir desc = inDir dir $ do
initRepo' desc
getUUID
initRepo' :: Maybe String -> Annex ()
initRepo' desc = do
unlessM isInitialized $ unlessM isInitialized $
initialize desc initialize desc
getUUID
{- Checks if the user can write to a directory. {- Checks if the user can write to a directory.
- -

View file

@ -32,6 +32,7 @@ import Utility.FileMode
import Config import Config
import Annex.Direct import Annex.Direct
import Annex.Content.Direct import Annex.Content.Direct
import Annex.Environment
import Backend import Backend
genDescription :: Maybe String -> Annex String genDescription :: Maybe String -> Annex String
@ -53,11 +54,14 @@ initialize mdescription = do
setVersion defaultVersion setVersion defaultVersion
checkCrippledFileSystem checkCrippledFileSystem
checkFifoSupport checkFifoSupport
Annex.Branch.create
gitPreCommitHookWrite gitPreCommitHookWrite
createInodeSentinalFile createInodeSentinalFile
u <- getUUID u <- getUUID
describeUUID u =<< genDescription mdescription {- This will make the first commit to git, so ensure git is set up
- properly to allow commits when running it. -}
ensureCommit $ do
Annex.Branch.create
describeUUID u =<< genDescription mdescription
uninitialize :: Annex () uninitialize :: Annex ()
uninitialize = do uninitialize = do

3
debian/changelog vendored
View file

@ -12,6 +12,9 @@ git-annex (4.20130628) UNRELEASED; urgency=low
automatically update its working copy when git annex sync or the assistant automatically update its working copy when git annex sync or the assistant
sync with it. sync with it.
* webapp: Fix ssh setup with nonstandard port, broken in last release. * webapp: Fix ssh setup with nonstandard port, broken in last release.
* init: Detect systems on which git commit fails due to not being able to
determine the FQDN, and put in a workaround so committing to the git-annex
branch works.
-- Joey Hess <joeyh@debian.org> Tue, 02 Jul 2013 15:40:55 -0400 -- Joey Hess <joeyh@debian.org> Tue, 02 Jul 2013 15:40:55 -0400

View file

@ -15,3 +15,6 @@ When clicking on "View logs", I get the following error:
### What version of git-annex are you using? On what operating system? ### What version of git-annex are you using? On what operating system?
- git-annex 4.20130627 on Ubuntu 13.10, installed from debian unstable (sid) repository. - git-annex 4.20130627 on Ubuntu 13.10, installed from debian unstable (sid) repository.
- git version 1.8.1.2 - git version 1.8.1.2
> I've made it detect systems that lack a FQDN and set user.email
> automatically. [[done]] --[[Joey]]