mirror of
https://github.com/kowainik/hit-on.git
synced 2024-09-11 12:15:46 +03:00
Resolves #109
This commit is contained in:
parent
e6939b5c81
commit
fd36f10767
@ -64,6 +64,8 @@ The changelog is available [on GitHub][2].
|
||||
* [#135](https://github.com/kowainik/hit-on/issues/135):
|
||||
Implement `hit stash diff`, `hit stash list`, `hit stash clear` commands.
|
||||
Add `--name` option to `hit stash` for named stashes.
|
||||
* [#109](https://github.com/kowainik/hit-on/issues/109):
|
||||
Do not fail on `hit fresh` when unsuccessful rebasing.
|
||||
|
||||
### 0.1.0.0 — Aug 3, 2019
|
||||
|
||||
|
@ -13,13 +13,25 @@ module Hit.Git.Fresh
|
||||
( runFresh
|
||||
) where
|
||||
|
||||
import Shellmet ()
|
||||
import Colourista (errorMessage, infoMessage, warningMessage)
|
||||
import Shellmet (($?))
|
||||
import System.IO (hFlush)
|
||||
|
||||
import Hit.Git.Common (nameOrMaster)
|
||||
import Hit.Prompt (Answer (..), arrow, prompt, yesOrNoText)
|
||||
|
||||
|
||||
-- | @hit fresh@ command.
|
||||
runFresh :: Maybe Text -> IO ()
|
||||
runFresh (nameOrMaster -> branch) = do
|
||||
"git" ["fetch", "origin", branch]
|
||||
"git" ["rebase", "origin/" <> branch]
|
||||
isRebase <- (True <$ "git" ["rebase", "origin/" <> branch]) $? pure False
|
||||
unless isRebase $ do
|
||||
errorMessage " 'git rebase' failed."
|
||||
putTextLn $ " Do you want to abort the command? " <> yesOrNoText Y
|
||||
putText arrow >> hFlush stdout
|
||||
prompt Y >>= \case
|
||||
Y -> do
|
||||
infoMessage "Aborting the command."
|
||||
"git" ["rebase", "--abort"] $? pass
|
||||
N -> warningMessage "Unsuccessful 'hit fresh' while rebasing."
|
||||
|
@ -18,7 +18,8 @@ module Hit.Prompt
|
||||
, arrow
|
||||
) where
|
||||
|
||||
import Colourista (bold, errorMessage, reset)
|
||||
import Colourista (errorMessage)
|
||||
import Colourista.Short (b)
|
||||
|
||||
import qualified Data.Text as T
|
||||
|
||||
@ -41,8 +42,8 @@ yesOrNoWithDefault def (T.toLower -> answer )
|
||||
| otherwise = Nothing
|
||||
|
||||
yesOrNoText :: Answer -> Text
|
||||
yesOrNoText N = "y/" <> bold <> "[n]" <> reset
|
||||
yesOrNoText Y = bold <> "[y]" <> reset <> "/n"
|
||||
yesOrNoText N = "y/" <> b "[n]"
|
||||
yesOrNoText Y = b "[y]" <> "/n"
|
||||
|
||||
-- | Prompt user for y/n input. Takes a default 'Answer' for the case of empty user input.
|
||||
prompt :: Answer -> IO Answer
|
||||
|
Loading…
Reference in New Issue
Block a user