-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremerge.hs
More file actions
26 lines (23 loc) · 723 Bytes
/
remerge.hs
File metadata and controls
26 lines (23 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{-# LANGUAGE LambdaCase #-}
import GitUtils
import Data.Maybe (fromMaybe)
main :: IO ()
main =
cmd "git log --merges --pretty=format:%P -n 1" >>=
\case
Nothing -> putStrLn "git log failed?"
Just [] -> putStrLn "No merges before this point"
Just [_] -> putStrLn "Error: Merge of single parent?"
Just [x, y] ->
do
_ <- cmd ("git checkout " <> x)
cmd ("git merge " <> y)
>>=
\case
Just{} -> cmd "git checkout HEAD^" >> main
Nothing ->
do
putStrLn "Remerge:\n"
cmd "git status" >>= putStr . fromMaybe ""
Just{} -> putStrLn "Merge of more than two parents not supported!"
. fmap words