This commit is contained in:
Joey Hess 2012-01-13 21:06:00 -04:00
parent 5481528058
commit ff5703ce77

View file

@ -57,7 +57,7 @@ fromCurrent = do
fromCwd :: IO Repo fromCwd :: IO Repo
fromCwd = getCurrentDirectory >>= seekUp isRepoTop >>= maybe norepo makerepo fromCwd = getCurrentDirectory >>= seekUp isRepoTop >>= maybe norepo makerepo
where where
makerepo = return . newFrom . Dir makerepo = newFrom . Dir
norepo = error "Not in a git repository." norepo = error "Not in a git repository."
{- Local Repo constructor, accepts a relative or absolute path. -} {- Local Repo constructor, accepts a relative or absolute path. -}
@ -88,7 +88,7 @@ fromAbsPath dir
else ret dir else ret dir
| otherwise = error $ "internal error, " ++ dir ++ " is not absolute" | otherwise = error $ "internal error, " ++ dir ++ " is not absolute"
where where
ret = return . newFrom . Dir ret = newFrom . Dir
{- Remote Repo constructor. Throws exception on invalid url. {- Remote Repo constructor. Throws exception on invalid url.
- -
@ -103,14 +103,14 @@ fromUrl url
fromUrlStrict :: String -> IO Repo fromUrlStrict :: String -> IO Repo
fromUrlStrict url fromUrlStrict url
| startswith "file://" url = fromAbsPath $ uriPath u | startswith "file://" url = fromAbsPath $ uriPath u
| otherwise = return $ newFrom $ Url u | otherwise = newFrom $ Url u
where where
u = fromMaybe bad $ parseURI url u = fromMaybe bad $ parseURI url
bad = error $ "bad url " ++ url bad = error $ "bad url " ++ url
{- Creates a repo that has an unknown location. -} {- Creates a repo that has an unknown location. -}
fromUnknown :: IO Repo fromUnknown :: IO Repo
fromUnknown = return $ newFrom Unknown fromUnknown = newFrom Unknown
{- Converts a local Repo into a remote repo, using the reference repo {- Converts a local Repo into a remote repo, using the reference repo
- which is assumed to be on the same host. -} - which is assumed to be on the same host. -}
@ -248,12 +248,11 @@ isRepoTop dir = do
(doesDirectoryExist (dir ++ "/" ++ subdir)) (doesDirectoryExist (dir ++ "/" ++ subdir))
(doesFileExist (dir ++ "/" ++ file)) (doesFileExist (dir ++ "/" ++ file))
newFrom :: RepoLocation -> Repo newFrom :: RepoLocation -> IO Repo
newFrom l = newFrom l = return Repo
Repo { { location = l
location = l, , config = M.empty
config = M.empty, , fullconfig = M.empty
fullconfig = M.empty, , remotes = []
remotes = [], , remoteName = Nothing
remoteName = Nothing
} }