diff options
author | Joey Hess <joey@kitenet.net> | 2012-08-03 10:45:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-08-03 10:45:22 -0400 |
commit | b618bd8b8e57e5691e15325df9798ef9b7a472e7 (patch) | |
tree | cc6d50d65eb55f90729b668b00a624d184fedaac /Init.hs | |
parent | a323b0c46dcb64eeb97ae8fa370a4a7b848cae7a (diff) | |
parent | abde98cda21d5deeb16ed3baf736b06fdc2fce2f (diff) |
Merge branch 'master' into assistant
Diffstat (limited to 'Init.hs')
-rw-r--r-- | Init.hs | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -20,6 +20,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 @@ -27,7 +47,7 @@ initialize mdescription = do setVersion gitPreCommitHookWrite u <- getUUID - maybe (recordUUID u) (describeUUID u) mdescription + describeUUID u =<< genDescription mdescription uninitialize :: Annex () uninitialize = do |