vpop N
This commit is contained in:
parent
8ff05cf55b
commit
1a53c87057
3 changed files with 16 additions and 8 deletions
|
@ -17,27 +17,32 @@ import Command.View (checkoutViewBranch)
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [notBareRepo $ notDirect $
|
def = [notBareRepo $ notDirect $
|
||||||
command "vpop" paramNothing seek SectionUtility
|
command "vpop" (paramOptional paramNumber) seek SectionUtility
|
||||||
"switch back to previous view"]
|
"switch back to previous view"]
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
seek = withNothing start
|
seek = withWords start
|
||||||
|
|
||||||
start ::CommandStart
|
start :: [String] -> CommandStart
|
||||||
start = go =<< currentView
|
start ps = go =<< currentView
|
||||||
where
|
where
|
||||||
go Nothing = error "Not in a view."
|
go Nothing = error "Not in a view."
|
||||||
go (Just v) = do
|
go (Just v) = do
|
||||||
showStart "vpop" ""
|
showStart "vpop" (show num)
|
||||||
removeView v
|
removeView v
|
||||||
vs <- filter (sameparentbranch v) <$> recentViews
|
vs <- drop (num - 1) . filter (sameparentbranch v)
|
||||||
|
<$> recentViews
|
||||||
case vs of
|
case vs of
|
||||||
(oldv:_) -> next $ next $ do
|
(oldv:_) -> next $ next $ do
|
||||||
|
showOutput
|
||||||
checkoutViewBranch oldv (return . branchView)
|
checkoutViewBranch oldv (return . branchView)
|
||||||
_ -> next $ next $
|
_ -> next $ next $ do
|
||||||
|
showOutput
|
||||||
inRepo $ Git.Command.runBool
|
inRepo $ Git.Command.runBool
|
||||||
[ Param "checkout"
|
[ Param "checkout"
|
||||||
, Param $ show $ Git.Ref.base $
|
, Param $ show $ Git.Ref.base $
|
||||||
viewParentBranch v
|
viewParentBranch v
|
||||||
]
|
]
|
||||||
sameparentbranch a b = viewParentBranch a == viewParentBranch b
|
sameparentbranch a b = viewParentBranch a == viewParentBranch b
|
||||||
|
|
||||||
|
num = fromMaybe 1 $ readish =<< headMaybe ps
|
||||||
|
|
|
@ -70,6 +70,7 @@ checkoutViewBranch view mkbranch = do
|
||||||
liftIO . setCurrentDirectory =<< fromRepo Git.repoPath
|
liftIO . setCurrentDirectory =<< fromRepo Git.repoPath
|
||||||
branch <- mkbranch view
|
branch <- mkbranch view
|
||||||
|
|
||||||
|
showOutput
|
||||||
ok <- inRepo $ Git.Command.runBool
|
ok <- inRepo $ Git.Command.runBool
|
||||||
[ Param "checkout"
|
[ Param "checkout"
|
||||||
, Param (show $ Git.Ref.base branch)
|
, Param (show $ Git.Ref.base branch)
|
||||||
|
|
|
@ -326,11 +326,13 @@ subdirectories).
|
||||||
When multiple field values match, the view branch will have a
|
When multiple field values match, the view branch will have a
|
||||||
subdirectory for each value.
|
subdirectory for each value.
|
||||||
|
|
||||||
* `vpop`
|
* `vpop [N]`
|
||||||
|
|
||||||
Switches from the currently active view back to the previous view.
|
Switches from the currently active view back to the previous view.
|
||||||
Or, from the first view back to original branch.
|
Or, from the first view back to original branch.
|
||||||
|
|
||||||
|
The optional number tells how many views to pop.
|
||||||
|
|
||||||
* `vadd [field=value ...] [tag ...]`
|
* `vadd [field=value ...] [tag ...]`
|
||||||
|
|
||||||
Refines the currently checked out view branch, adding additional fields
|
Refines the currently checked out view branch, adding additional fields
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue