improve type signatures with a Ref newtype
In git, a Ref can be a Sha, or a Branch, or a Tag. I added type aliases for those. Note that this does not prevent mixing up of eg, refs and branches at the type level. Since git really doesn't care, except rare cases like git update-ref, or git tag -d, that seems ok for now. There's also a tree-ish, but let's just use Ref for it. A given Sha or Ref may or may not be a tree-ish, depending on the object type, so there seems no point in trying to represent it at the type level.
This commit is contained in:
parent
272a67921c
commit
9290095fc2
10 changed files with 86 additions and 71 deletions
|
@ -26,9 +26,9 @@ check :: Annex ()
|
|||
check = do
|
||||
b <- current_branch
|
||||
when (b == Annex.Branch.name) $ error $
|
||||
"cannot uninit when the " ++ b ++ " branch is checked out"
|
||||
"cannot uninit when the " ++ show b ++ " branch is checked out"
|
||||
where
|
||||
current_branch = head . lines . B.unpack <$> revhead
|
||||
current_branch = Git.Ref . head . lines . B.unpack <$> revhead
|
||||
revhead = inRepo $ Git.pipeRead
|
||||
[Params "rev-parse --abbrev-ref HEAD"]
|
||||
|
||||
|
@ -57,5 +57,5 @@ cleanup = do
|
|||
liftIO $ removeDirectoryRecursive annexdir
|
||||
-- avoid normal shutdown
|
||||
saveState
|
||||
inRepo $ Git.run "branch" [Param "-D", Param Annex.Branch.name]
|
||||
inRepo $ Git.run "branch" [Param "-D", Param $ show Annex.Branch.name]
|
||||
liftIO exitSuccess
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue