packages feed

git-brunch 1.0.4.0 → 1.0.5.0

raw patch · 4 files changed

+90/−21 lines, 4 filesdep +hspecPVP ok

version bump matches the API change (PVP)

Dependencies added: hspec

API changes (from Hackage documentation)

+ Git: instance GHC.Classes.Eq Git.Branch
+ Git: toBranches :: String -> [Branch]

Files

README.md view
@@ -8,7 +8,7 @@  Run `git-brunch` or `git brunch`. -## Git alias (optional)+### Git alias (optional)  ```sh git config --global alias.b brunch@@ -18,26 +18,39 @@  ### Download binary -Download from [releases](https://github.com/andys8/git-brunch/releases), rename to `git-brunch` and add to `PATH`.+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` -### Install with `stack`+### [Stack](https://haskellstack.org) +#### Install+ ```sh-stack install --resolver=lts-14 git-brunch+stack install git-brunch # --resolver=lts-14 ``` -### Clone and install with `nix`+#### Clone and install from source  ```sh git clone https://github.com/andys8/git-brunch.git cd git-brunch-nix-env -if default.nix+stack install ``` -### Clone and install with `stack` from source+### [Nix](https://nixos.org/nix) +#### Install+ ```sh+nix-env -f "<nixpkgs>" -iA haskellPackages.git-brunch+```++#### Clone and install with `nix`++```sh git clone https://github.com/andys8/git-brunch.git cd git-brunch-stack install+nix-env -if . ```
git-brunch.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 407ffbc23a3da9726721f4645e1dadf91411c6068242303a3995986f4191cd1c+-- hash: 04ccac3b833e799f1ab4caf4aecc4d2683bb9be8dc91f06c9f5f89d78141a8e7  name:           git-brunch-version:        1.0.4.0+version:        1.0.5.0 synopsis:       git checkout command-line tool description:    Please see the README on GitHub at <https://github.com/andys8/git-brunch#readme> category:       Git@@ -76,6 +76,7 @@       base >=4.7 && <5     , brick     , git-brunch-lib+    , hspec     , microlens     , process     , vector
src/Git.hs view
@@ -1,6 +1,7 @@ module Git   ( listBranches   , checkout+  , toBranches   , Branch(..)   ) where@@ -13,6 +14,7 @@ data Branch = BranchLocal String             | BranchCurrent String             | BranchRemote String String+            deriving Eq   instance (Show Branch) where@@ -37,18 +39,17 @@   toBranches :: String -> [Branch]-toBranches input = filter (not . isHead) $ toBranch <$> lines input+toBranches input = toBranch <$> filter (not . isHead) (lines input)   toBranch :: String -> Branch-toBranch line = toBranch' $ head $ words $ drop 2 line+toBranch line = toBranch' $ words $ dropWhile isSpace line  where-  isCurrent = "*" `isPrefixOf` line-  toBranch' name-    | isCurrent = BranchCurrent name-    | otherwise = case stripPrefix "remotes/" name of-      Just rest -> parseRemoteBranch rest-      Nothing   -> BranchLocal name+  toBranch' ("*" : name : _) = BranchCurrent name+  toBranch' (name       : _) = case stripPrefix "remotes/" name of+    Just rest -> parseRemoteBranch rest+    Nothing   -> BranchLocal name+  toBranch' [] = error "empty branch name"   checkout :: Branch -> IO (Either String String)@@ -72,5 +73,5 @@ branchName (BranchRemote _ n) = n  -isHead :: Branch -> Bool-isHead = (== "HEAD") . branchName+isHead :: String -> Bool+isHead name = isInfixOf "HEAD" name
test/Spec.hs view
@@ -1,2 +1,56 @@+import           Test.Hspec+import           Git+ main :: IO ()-main = putStrLn "Test suite not yet implemented"+main = hspec $ describe "Git.toBranch" $ do++    it "returns a remote branch is starts with remote"+        $          toBranches "remotes/origin/master"+        `shouldBe` [BranchRemote "origin" "master"]++    it "ignores leading spaces"+        $          toBranches "  master"+        `shouldBe` [BranchLocal "master"]++    it "detects current branch by asterik"+        $          toBranches "* master"+        `shouldBe` [BranchCurrent "master"]++    it "returns a local branch"+        $          toBranches "master"+        `shouldBe` [BranchLocal "master"]++    it "returns a branch with head in name"+        $          toBranches "updateHead"+        `shouldBe` [BranchLocal "updateHead"]++    it "ignores HEAD" $ toBranches "HEAD" `shouldBe` []++    it "ignores origin/HEAD" $ toBranches "origin/HEAD" `shouldBe` []++    it "ignores detatched HEAD"+        $          toBranches "* (HEAD detached at f01a202)"+        `shouldBe` []++    it "parses sample output"+        $          toBranches sampleOutput+        `shouldBe` [ BranchLocal "experimental/failing-debug-log-demo"+                   , BranchLocal "gh-pages"+                   , BranchLocal "master"+                   , BranchLocal "wip/delete-as-action"+                   , BranchRemote "origin" "experimental/failing-debug-log-demo"+                   , BranchRemote "origin" "gh-pages"+                   , BranchRemote "origin" "master"+                   ]++sampleOutput :: String+sampleOutput =+    "* (HEAD detached at f01a202)\n"+        ++ "  experimental/failing-debug-log-demo\n"+        ++ "  gh-pages\n"+        ++ "  master\n"+        ++ "  wip/delete-as-action\n"+        ++ "  remotes/origin/HEAD -> origin/master\n"+        ++ "  remotes/origin/experimental/failing-debug-log-demo\n"+        ++ "  remotes/origin/gh-pages\n"+        ++ "  remotes/origin/master"