git-brunch 1.4.4.0 → 1.5.0.0
raw patch · 7 files changed
+86/−64 lines, 7 files
Files
- README.md +33/−22
- app/Git.hs +7/−2
- app/GitBrunch.hs +31/−27
- app/Main.hs +2/−2
- app/Theme.hs +3/−3
- git-brunch.cabal +9/−7
- test/Spec.hs +1/−1
README.md view
@@ -1,13 +1,13 @@ # git-brunch [](https://travis-ci.org/andys8/git-brunch)  -A git branch checkout command-line tool+A git command-line tool to work with branches  ## Features -- Checkout local or remote branch-- Rebase onto a branch+- Quickly checkout local or remote branch+- Merge or rebase a branch - Search for a branch - Delete a branch - Fetch / Update@@ -18,54 +18,65 @@ ### Git alias (optional) +An alias like `git b` (or `gb`) is a good idea to quickly access the tool.+ ```sh git config --global alias.b brunch ``` ## Installation +The installation is possible in multiple ways, and there are binaries available to download.+ ### Download binary -1. Download from [releases](https://github.com/andys8/git-brunch/releases)-1. Rename to `git-brunch`-1. `chmod +x git-brunch`-1. Add to `PATH`+1. Download from **[releases](https://github.com/andys8/git-brunch/releases)**+1. Rename the file to `git-brunch`+1. Make it executable with `chmod +x git-brunch`+1. Add to your `PATH` ### Arch Linux -`git-brunch` is in the [AUR](https://aur.archlinux.org/packages/git-brunch).-Install it with e.g. `yay -S git-brunch` or `pamac install git-brunch`.+`git-brunch` is in the [AUR](https://aur.archlinux.org/packages/git-brunch) -### [Stack](https://haskellstack.org)+```sh+yay -S git-brunch+pamac install git-brunch+``` -#### Install+### FreeBSD +`git-brunch` can be installed from the official FreeBSD package repository+ ```sh-stack install git-brunch # --resolver=lts-16.11+pkg install hs-git-brunch ``` -#### Clone and install from source+### [Nix](https://nixos.org/nix) +`git-brunch` is part of the nix package manager+ ```sh-git clone https://github.com/andys8/git-brunch.git-cd git-brunch-stack install+nix-env -i git-brunch ``` -### [Nix](https://nixos.org/nix)+### [Stack](https://haskellstack.org) -#### Install with nix-env+`git-brunch` can installed with the Haskell build tool stack ```sh-nix-env -f "<nixpkgs>" -iA haskellPackages.git-brunch+stack install git-brunch # --resolver=lts-17.4 ``` -#### Clone and install with `nix`+### Install from source +`git-brunch` can be installed from source. It can be forked and modified, if you like to.+ ```sh-git clone https://github.com/andys8/git-brunch.git+git clone https://github.com/andys8/git-brunch cd git-brunch-nix-env -if .+stack install+# or nix-env -if . ``` ## Development
app/Git.hs view
@@ -8,9 +8,9 @@ , isRemoteBranch , listBranches , rebaseInteractive+ , merge , toBranches- )-where+ ) where import Data.Char ( isSpace ) import Data.List@@ -63,6 +63,11 @@ rebaseInteractive branch = do putStrLn $ "Rebase onto " <> fullBranchName branch spawnGit ["rebase", "--interactive", "--autostash", fullBranchName branch]++merge :: Branch -> IO ExitCode+merge branch = do+ putStrLn $ "Merge branch " <> fullBranchName branch+ spawnGit ["merge", fullBranchName branch] deleteBranch :: Branch -> IO ExitCode deleteBranch (BranchCurrent _ ) = error "Cannot delete current branch"
app/GitBrunch.hs view
@@ -1,16 +1,22 @@ {-# LANGUAGE LambdaCase #-} module GitBrunch ( main- )-where+ ) where -import Brick.Main ( halt- , continue+import Brick.Main ( continue+ , halt , suspendAndResume )+import qualified Brick.Main as M import Brick.Themes ( themeToAttrMap ) import Brick.Types+import qualified Brick.Widgets.Border as B+import qualified Brick.Widgets.Border.Style as BS+import qualified Brick.Widgets.Center as C import Brick.Widgets.Core+import qualified Brick.Widgets.Dialog as D+import qualified Brick.Widgets.Edit as E+import qualified Brick.Widgets.List as L import Control.Exception ( SomeException , catch )@@ -18,51 +24,45 @@ import Data.Char import Data.List import Data.Maybe ( fromMaybe )+import qualified Data.Vector as Vec import Graphics.Vty hiding ( update )-import Lens.Micro ( (^.)- , (.~)- , (%~)+import Lens.Micro ( (%~) , (&)+ , (.~) , Lens'+ , (^.) , lens ) import System.Exit-import qualified Brick.Main as M-import qualified Brick.Widgets.Border as B-import qualified Brick.Widgets.Border.Style as BS-import qualified Brick.Widgets.Center as C-import qualified Brick.Widgets.Dialog as D-import qualified Brick.Widgets.Edit as E-import qualified Brick.Widgets.List as L-import qualified Data.Vector as Vec import Git ( Branch(..) )-import Theme import qualified Git+import Theme data Name = Local | Remote | Filter deriving (Ord, Eq, Show) data RemoteName = RLocal | RRemote deriving (Eq)-data GitCommand = GitRebase | GitCheckout | GitDeleteBranch deriving (Ord, Eq)+data GitCommand = GitRebase | GitMerge | GitCheckout | GitDeleteBranch deriving (Ord, Eq) data DialogResult = SetDialog Dialog | EndDialog DialogOption data DialogOption = Cancel | Confirm type Dialog = D.Dialog DialogOption data State = State- { _focus :: RemoteName- , _gitCommand :: GitCommand- , _branches :: [Branch]- , _localBranches :: L.List Name Branch- , _remoteBranches :: L.List Name Branch- , _dialog :: Maybe Dialog- , _filter :: E.Editor String Name+ { _focus :: RemoteName+ , _gitCommand :: GitCommand+ , _branches :: [Branch]+ , _localBranches :: L.List Name Branch+ , _remoteBranches :: L.List Name Branch+ , _dialog :: Maybe Dialog+ , _filter :: E.Editor String Name , _isEditingFilter :: Bool } -instance (Show GitCommand) where+instance Show GitCommand where show GitCheckout = "checkout" show GitRebase = "rebase"+ show GitMerge = "merge" show GitDeleteBranch = "delete" @@ -81,6 +81,7 @@ gitFunction = \case GitCheckout -> Git.checkout GitRebase -> Git.rebaseInteractive+ GitMerge -> Git.merge GitDeleteBranch -> Git.deleteBranch emptyState :: State@@ -126,11 +127,11 @@ , C.hCenter $ toBranchList RRemote remoteBranchesL ] instructions = maxWidth 100 $ hBox- [ drawInstruction "HJKL" "move"- , drawInstruction "Enter" "checkout"+ [ drawInstruction "Enter" "checkout" , drawInstruction "/" "filter" , drawInstruction "F" "fetch" , drawInstruction "R" "rebase"+ , drawInstruction "M" "merge" , drawInstruction "D" "delete" ] @@ -225,6 +226,7 @@ confirmDelete Nothing = continue state endWithCheckout = halt $ state { _gitCommand = GitCheckout } endWithRebase = halt $ state { _gitCommand = GitRebase }+ endWithMerge = halt $ state { _gitCommand = GitMerge } focusLocal = focusBranches RLocal state focusRemote = focusBranches RRemote state doFetch = suspendAndResume (fetchBranches state)@@ -245,7 +247,9 @@ EvKey (KChar 'f') [MCtrl] -> startEditingFilter EvKey (KChar 'd') [] -> confirmDelete (selectedBranch state) EvKey KEnter [] -> endWithCheckout+ EvKey (KChar 'c') [] -> endWithCheckout EvKey (KChar 'r') [] -> endWithRebase+ EvKey (KChar 'm') [] -> endWithMerge EvKey KLeft [] -> focusLocal EvKey (KChar 'h') [] -> focusLocal EvKey KRight [] -> focusRemote
app/Main.hs view
@@ -1,8 +1,8 @@ module Main where +import Data.Version ( showVersion ) import Options.Applicative import Paths_git_brunch ( version )-import Data.Version ( showVersion ) import qualified GitBrunch @@ -15,7 +15,7 @@ where opts = info (versionParser <|> pure RunGitBrunch <**> helper)- (header "git-brunch - A git checkout and rebase command-line tool")+ (header "git-brunch - A git command-line tool to work with branches") run :: Mode -> IO ()
app/Theme.hs view
@@ -5,11 +5,11 @@ ) import Brick.Themes import Brick.Util-import Graphics.Vty-import qualified Brick.Widgets.Dialog as Dialog-import qualified Brick.Widgets.List as List import Brick.Widgets.Border as Border+import qualified Brick.Widgets.Dialog as Dialog import qualified Brick.Widgets.Edit as Edit+import qualified Brick.Widgets.List as List+import Graphics.Vty theme :: Theme theme = newTheme
git-brunch.cabal view
@@ -1,13 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: 643cd917a331afd2c5c769ae081cd6f382eec74c30471e6b5b3ac9315c3df792 name: git-brunch-version: 1.4.4.0+version: 1.5.0.0 synopsis: git checkout command-line tool description: Please see the README on GitHub at <https://github.com/andys8/git-brunch> category: Git@@ -15,7 +13,7 @@ bug-reports: https://github.com/andys8/git-brunch/issues author: andys8 maintainer: andys8@users.noreply.github.com-copyright: 2020 andys8+copyright: 2021 andys8 license: BSD3 license-file: LICENSE build-type: Simple@@ -39,7 +37,9 @@ Paths_git_brunch hs-source-dirs: app- default-extensions: StrictData OverloadedStrings+ default-extensions:+ StrictData+ OverloadedStrings build-depends: base >=4.7 && <5 , brick@@ -65,7 +65,9 @@ hs-source-dirs: test app- default-extensions: StrictData OverloadedStrings+ default-extensions:+ StrictData+ OverloadedStrings ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: base >=4.7 && <5
test/Spec.hs view
@@ -1,5 +1,5 @@-import Test.Hspec import Git+import Test.Hspec main :: IO () main = hspec $ describe "Git.toBranch" $ do