packages feed

Hish 0.1.0 → 0.1.0.1

raw patch · 2 files changed

+65/−1 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Hish.cabal view
@@ -1,5 +1,5 @@ Name:                   Hish-Version:                0.1.0+Version:                0.1.0.1 Author:                 Yun-Yan Chi Maintainer:             jaiyalas@gmail.com License:                BSD3@@ -27,6 +27,7 @@   exposed-modules:         Hish.ANSICode         Hish.SysInfo+        Hish.VCS  -- executable hish
+ src/Hish/VCS.hs view
@@ -0,0 +1,63 @@+module Hish.VCS+   (+   -- * Version Control System+     VCS   (..)+   -- ** Git+   , Git   (..)+   -- ** Darcs+   , Darcs (..)+   ) where++import Text.Regex.TDFA ((=~))+import qualified Data.String.Utils as S (replace)+import qualified Data.List as DL (lines)+++-- | Every version control system provides functions as follows+--+class VCS a where+   -- | tracking ahead+   vcsAhead :: a -> String -> Maybe String+   -- | tracking behind+   vcsBehind :: a -> String -> Maybe String+   -- | determining the cleanliness of working-tree+   --+   --       * __#__ - /clean/ working directory+   --       * __?__ - /clean/ but existing untracked file+   --       * __*__ - /dirty/+   vcsCleanliness :: a -> String -> Maybe String+   vcsCurrentBranch :: a -> String -> Maybe String++-- | Unit type for presenting Git.+data Git = Git++instance VCS Git where+   vcsAhead _ s =+      case (s =~ "ahead [0-9]+"  :: String) of+         []    -> Nothing+         ahead -> Just $ S.replace "ahead " "" ahead+   vcsBehind _ s =+      case (s =~ "behind [0-9]+"  :: String) of+         []    -> Nothing+         behind -> Just $ S.replace "behind " "" behind+   vcsCleanliness _ s = let body = tail $ DL.lines s in+      case body of+         [] -> Just "#"+         _  -> let (index,tree) = unzip $ map ((\ (a:b:_)->(a,b)).take 2) body in+            if ("" == (filter (/='?') tree))+               then Just "?"+               else Just "*"+   vcsCurrentBranch _ = Just+      . drop 2+      . head+      . filter ((=='*').head)+      . lines++-- | Unit type for presenting Darcs.+-- /UN-IMPLEMENTED/!+data Darcs = Darcs++instance VCS Darcs where+   vcsAhead _ s = return "a"+   vcsBehind _ s = return "b"+   vcsCleanliness _ s = return "?"