ignore 0.1.0.0 → 0.1.1.0
raw patch · 6 files changed
+81/−28 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +35/−18
- ignore.cabal +10/−2
- src/Ignore/Builder.hs +9/−1
- src/Ignore/VCS/Darcs.hs +12/−2
- src/Ignore/VCS/Git.hs +3/−2
- src/Ignore/VCS/Mercurial.hs +12/−3
README.md view
@@ -2,15 +2,30 @@ ===== [](https://travis-ci.org/agrafix/ignore)+[](http://hackage.haskell.org/package/ignore) ## Intro Hackage: [ignore](http://hackage.haskell.org/package/ignore)+Stackage: [ignore](https://www.stackage.org/package/ignore) -Library and tiny tool for working with ignore files of different version control systems.+Handle ignore files of different VCSes -## Library Usage+## Cli Usage: ignore +```sh+$ ignore --help+The ignore tool+(c) 2015 Alexander Thiemann++Tiny tool to check if a file in a repo is ignored by a VCS++Usage: ignore [--help|-h] file1 file2 file3 ... fileN++```++## Library Usage Example+ ```haskell module Main where @@ -28,25 +43,27 @@ case checker of Left err -> error err Right (FileIgnoredChecker isFileIgnored) ->- putStrLn $ - "Main.hs is " - ++ (if isFileIgnored "Main.hs" - then "ignored" else "not ignored")-```--## Commandline Usage--Run in any project under version control to check if a file is ignored or not.+ putStrLn $+ "Main.hs is "+ ++ (if isFileIgnored "Main.hs"+ then "ignored" else "not ignored") -```bash-$ ignore foo~ dist/bar distinct-File foo~ IGNORED-File dist/foo IGNORED-File distinct not ignored ``` ## Install * Using cabal: `cabal install ignore`-* From Source: `git clone https://github.com/agrafix/ignore.git && cd ignore && cabal install`-* Using stack: `git clone https://github.com/agrafix/ignore.git && cd ignore && stack build`+* Using Stack: `stack install ignore`+* From Source (cabal): `git clone https://github.com/agrafix/ignore.git && cd ignore && cabal install`+* From Source (stack): `git clone https://github.com/agrafix/ignore.git && cd ignore && stack build`+++## Misc++### Supported GHC Versions+++### License++Released under the BSD3 license.+(c) 2015 Alexander Thiemann
ignore.cabal view
@@ -1,5 +1,5 @@ name: ignore-version: 0.1.0.0+version: 0.1.1.0 synopsis: Handle ignore files of different VCSes description: Library and tiny tool for working with ignore files of different version control systems homepage: http://github.com/agrafix/ignore@@ -13,6 +13,11 @@ extra-source-files: README.md cabal-version: >=1.10 +flag without-pcre+ manual: True+ default: False+ description: Disable pcre support. If you enable this flag, version control ignore files that rely on pcre will not work correctly+ library hs-source-dirs: src exposed-modules:@@ -27,11 +32,14 @@ build-depends: base >= 4 && < 5, path >= 0.5.1,- pcre-heavy >=0.2, Glob >=0.7, text >=1.2.0.4, mtl >=2.1.3.1, directory >= 1.2.1.0+ if !flag(without-pcre)+ build-depends: pcre-heavy >=0.2+ else+ cpp-options: -DNO_PCRE default-language: Haskell2010 executable ignore
src/Ignore/Builder.hs view
@@ -17,10 +17,12 @@ #else import Control.Monad.Error #endif+#ifndef NO_PCRE import Text.Regex.PCRE.Heavy ((=~))+import qualified Text.Regex.PCRE.Heavy as Re+#endif import qualified Data.Text as T import qualified Data.Text.Encoding as T-import qualified Text.Regex.PCRE.Heavy as Re import qualified System.FilePath.Glob as G #if MIN_VERSION_mtl(2,2,0)@@ -59,6 +61,11 @@ do let simplified = G.simplify pat lift $ tell $ FileIgnoredChecker (G.matchWith G.matchPosix simplified) +#ifdef NO_PCRE+registerRegex :: MonadIO m => T.Text -> CheckerBuilderT m ()+registerRegex rePattern =+ CheckerBuilderT $ return ()+#else registerRegex :: Monad m => T.Text -> CheckerBuilderT m () registerRegex rePattern = CheckerBuilderT $@@ -66,3 +73,4 @@ Left err -> throwError ("Failed to compile regex pattern " ++ T.unpack rePattern ++ ": " ++ err) Right pat -> lift $ tell $ FileIgnoredChecker (=~ pat)+#endif
src/Ignore/VCS/Darcs.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE TemplateHaskell #-} module Ignore.VCS.Darcs ( makeChecker@@ -7,16 +8,25 @@ import Ignore.Builder +import Control.Monad.Trans import Path import qualified Data.Text as T -makeChecker :: Monad m => [T.Text] -> CheckerBuilderT m ()+#ifdef NO_PCRE+makeChecker :: MonadIO m => [T.Text] -> CheckerBuilderT m ()+makeChecker _ =+ liftIO $+ do putStrLn "The ignore library was compiled with the without-pcre flag."+ putStrLn "This means that we can not handle darcs boring files for now."+#else+makeChecker :: MonadIO m => [T.Text] -> CheckerBuilderT m () makeChecker = go+#endif file :: Path Rel File file = $(mkRelDir "_darcs/prefs") </> $(mkRelFile "boring") -go :: Monad m => [T.Text] -> CheckerBuilderT m ()+go :: MonadIO m => [T.Text] -> CheckerBuilderT m () go [] = return () go (x : xs) | T.null ln = go xs
src/Ignore/VCS/Git.hs view
@@ -8,16 +8,17 @@ import Ignore.Builder +import Control.Monad.Trans import Path import qualified Data.Text as T -makeChecker :: Monad m => [T.Text] -> CheckerBuilderT m ()+makeChecker :: MonadIO m => [T.Text] -> CheckerBuilderT m () makeChecker = mapM_ handleLine file :: Path Rel File file = $(mkRelFile ".gitignore") -handleLine :: Monad m => T.Text -> CheckerBuilderT m ()+handleLine :: MonadIO m => T.Text -> CheckerBuilderT m () handleLine origLn | T.null ln = return () | T.head ln == '#' = return ()
src/Ignore/VCS/Mercurial.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE OverloadedStrings #-} module Ignore.VCS.Mercurial@@ -8,16 +9,24 @@ import Ignore.Builder +import Control.Monad.Trans import Path import qualified Data.Text as T -makeChecker :: Monad m => [T.Text] -> CheckerBuilderT m ()-makeChecker = go registerRegex+makeChecker :: MonadIO m => [T.Text] -> CheckerBuilderT m ()+makeChecker files =+ do+#ifdef NO_PCRE+ liftIO $+ do putStrLn "The ignore library was compiled with the without-pcre flag."+ putStrLn "This means it will only support 'syntax: glob' mercurial blocks"+#endif+ go registerRegex files file :: Path Rel File file = $(mkRelFile ".hgignore") -go :: Monad m => (T.Text -> CheckerBuilderT m ()) -> [T.Text] -> CheckerBuilderT m ()+go :: MonadIO m => (T.Text -> CheckerBuilderT m ()) -> [T.Text] -> CheckerBuilderT m () go _ [] = return () go register (x : xs) | T.null ln = go register xs