vpop: Only update state after successful checkout
If checkout fails for some reason, they're still in a view, and should be able to vpop again.
This commit is contained in:
parent
c8e83189f6
commit
447e6adabd
3 changed files with 42 additions and 6 deletions
|
@ -28,22 +28,29 @@ start ps = go =<< currentView
|
|||
where
|
||||
go Nothing = giveup "Not in a view."
|
||||
go (Just (v, madj)) = starting "vpop" ai si $ do
|
||||
removeView v
|
||||
(oldvs, vs) <- splitAt (num - 1) . filter (sameparentbranch v)
|
||||
(oldvs, vs) <- splitAt (num - 1)
|
||||
. filter (sameparentbranch v)
|
||||
. filter (/= v)
|
||||
<$> recentViews
|
||||
mapM_ removeView oldvs
|
||||
case vs of
|
||||
(oldv:_) -> next $ do
|
||||
let removeview = mapM_ removeView (v : oldvs)
|
||||
ok <- case vs of
|
||||
(oldv:_) -> do
|
||||
showOutput
|
||||
checkoutViewBranch oldv madj
|
||||
(\v' madj' -> return (branchView v' madj'))
|
||||
_ -> next $ do
|
||||
_ -> do
|
||||
showOutput
|
||||
inRepo $ Git.Command.runBool
|
||||
[ Param "checkout"
|
||||
, Param $ Git.fromRef $ Git.Ref.base $
|
||||
viewParentBranch v
|
||||
]
|
||||
if ok
|
||||
then
|
||||
next $ do
|
||||
removeview
|
||||
return True
|
||||
else next $ return False
|
||||
sameparentbranch a b = viewParentBranch a == viewParentBranch b
|
||||
|
||||
num = fromMaybe 1 $ readish =<< headMaybe ps
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue