summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-03 10:48:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-03 10:48:24 -0400
commitc3f94aa7447cbd4d5b38e40e37bd1710b87c21c8 (patch)
tree692e803aa374da09847fff135a20fa6792c5c26d
parent68802901ba5859d8d0fe888e13c4d606416a5671 (diff)
parentabde98cda21d5deeb16ed3baf736b06fdc2fce2f (diff)
Merge branch 'master' of ssh://git-annex.branchable.com
-rw-r--r--Init.hs22
-rw-r--r--debian/changelog2
-rw-r--r--doc/git-annex.mdwn3
3 files changed, 25 insertions, 2 deletions
diff --git a/Init.hs b/Init.hs
index bddcc696e..291e346f5 100644
--- a/Init.hs
+++ b/Init.hs
@@ -19,6 +19,26 @@ import Logs.UUID
import Annex.Version
import Annex.UUID
+import System.Posix.User
+
+genDescription :: Maybe String -> Annex String
+genDescription (Just d) = return d
+genDescription Nothing = do
+ hostname <- getHostname
+ let at = if null hostname then "" else "@"
+ username <- clicketyclickety
+ reldir <- liftIO . relHome =<< fromRepo Git.repoPath
+ return $ concat [username, at, hostname, ":", reldir]
+ where
+ {- Haskell lacks uname(2) bindings, except in the
+ - Bindings.Uname addon. Rather than depend on that,
+ - use uname -n when available. -}
+ getHostname = liftIO $ catchDefaultIO uname_node ""
+ uname_node = takeWhile (/= '\n') <$>
+ readProcess "uname" ["-n"]
+ clicketyclickety = liftIO $ userName <$>
+ (getUserEntryForID =<< getEffectiveUserID)
+
initialize :: Maybe String -> Annex ()
initialize mdescription = do
prepUUID
@@ -26,7 +46,7 @@ initialize mdescription = do
setVersion
gitPreCommitHookWrite
u <- getUUID
- maybe (recordUUID u) (describeUUID u) mdescription
+ describeUUID u =<< genDescription mdescription
uninitialize :: Annex ()
uninitialize = do
diff --git a/debian/changelog b/debian/changelog
index 82bf5009a..081d1ac9f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ git-annex (3.20120722) UNRELEASED; urgency=low
* initremote: Avoid recording remote's description before checking
that its config is valid.
+ * init: If no description is provided for a new repository, one will
+ automatically be generated, like "joey@gnu:~/foo"
-- Joey Hess <joeyh@debian.org> Fri, 27 Jul 2012 21:04:47 -0400
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index c52a5f3bf..a3fc82b55 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -194,7 +194,8 @@ subdirectories).
using it in a repository that was not intended to have an annex.
It's useful, but not mandatory, to initialize each new clone
- of a repository with its own description.
+ of a repository with its own description. If you don't provide one,
+ one will be generated.
* describe repository description