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:
parent
62f391480d
commit
d84a000e92
5 changed files with 37 additions and 7 deletions
|
@ -13,10 +13,19 @@ import Common.Annex
|
|||
import Utility.Env
|
||||
import Utility.UserInfo
|
||||
import qualified Git.Config
|
||||
import Config
|
||||
import Annex.Exception
|
||||
|
||||
{- Checks that the system's environment allows git to function.
|
||||
- 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 = do
|
||||
gitusername <- fromRepo $ Git.Config.getMaybe "user.name"
|
||||
|
@ -42,3 +51,12 @@ checkEnvironmentIO =
|
|||
ensureEnv _ _ = noop
|
||||
#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
|
||||
|
|
|
@ -366,9 +366,7 @@ inDir dir a = do
|
|||
{- Creates a new repository, and returns its UUID. -}
|
||||
initRepo :: Bool -> Bool -> FilePath -> Maybe String -> IO UUID
|
||||
initRepo True primary_assistant_repo dir desc = inDir dir $ do
|
||||
{- Initialize a git-annex repository in a directory with a description. -}
|
||||
unlessM isInitialized $
|
||||
initialize desc
|
||||
initRepo' desc
|
||||
{- Initialize the master branch, so things that expect
|
||||
- to have it will work, before any files are added. -}
|
||||
unlessM (Git.Config.isBare <$> gitRepo) $
|
||||
|
@ -391,9 +389,13 @@ initRepo True primary_assistant_repo dir desc = inDir dir $ do
|
|||
getUUID
|
||||
{- Repo already exists, could be a non-git-annex repo though. -}
|
||||
initRepo False _ dir desc = inDir dir $ do
|
||||
initRepo' desc
|
||||
getUUID
|
||||
|
||||
initRepo' :: Maybe String -> Annex ()
|
||||
initRepo' desc = do
|
||||
unlessM isInitialized $
|
||||
initialize desc
|
||||
getUUID
|
||||
|
||||
{- Checks if the user can write to a directory.
|
||||
-
|
||||
|
|
8
Init.hs
8
Init.hs
|
@ -32,6 +32,7 @@ import Utility.FileMode
|
|||
import Config
|
||||
import Annex.Direct
|
||||
import Annex.Content.Direct
|
||||
import Annex.Environment
|
||||
import Backend
|
||||
|
||||
genDescription :: Maybe String -> Annex String
|
||||
|
@ -53,11 +54,14 @@ initialize mdescription = do
|
|||
setVersion defaultVersion
|
||||
checkCrippledFileSystem
|
||||
checkFifoSupport
|
||||
Annex.Branch.create
|
||||
gitPreCommitHookWrite
|
||||
createInodeSentinalFile
|
||||
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 = do
|
||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -12,6 +12,9 @@ git-annex (4.20130628) UNRELEASED; urgency=low
|
|||
automatically update its working copy when git annex sync or the assistant
|
||||
sync with it.
|
||||
* 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
|
||||
|
||||
|
|
|
@ -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?
|
||||
- git-annex 4.20130627 on Ubuntu 13.10, installed from debian unstable (sid) repository.
|
||||
- git version 1.8.1.2
|
||||
|
||||
> I've made it detect systems that lack a FQDN and set user.email
|
||||
> automatically. [[done]] --[[Joey]]
|
||||
|
|
Loading…
Add table
Reference in a new issue