vcs-ignore: Library for handling files ignored by VCS systems.

[ bsd3, development, library, program ] [ Propose Tags ] [ Report a vulnerability ]

vcs-ignore is small Haskell library used to find, check and process files ignored by selected VCS.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.1.0, 0.0.2.0
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), containers, directory, exceptions, filepath, Glob, optparse-applicative, text, vcs-ignore [details]
License BSD-3-Clause
Copyright Copyright (c) 2020-2022 Vaclav Svejcar
Author Vaclav Svejcar
Maintainer vaclav.svejcar@gmail.com
Category Development
Home page https://github.com/vaclavsvejcar/vcs-ignore
Bug tracker https://github.com/vaclavsvejcar/vcs-ignore/issues
Source repo head: git clone https://github.com/vaclavsvejcar/vcs-ignore
Uploaded by xwinus at 2021-12-29T21:00:16Z
Distributions LTSHaskell:0.0.2.0, NixOS:0.0.2.0, Stackage:0.0.2.0
Reverse Dependencies 1 direct, 0 indirect [details]
Executables ignore
Downloads 772 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-12-29 [all 1 reports]

Readme for vcs-ignore-0.0.2.0

[back to package description]

CI Hackage version Stackage version

vcs-ignore

vcs-ignore is small Haskell library used to find, check and process files ignored by selected VCS.

1. Table of Contents

2. Use as Library

Because this library is really simple to use, following example should be enough to understand how to use it for your project.

2.1. Listing all files/directories ignored by VCS

{-# LANGUAGE TypeApplications #-}

module Data.VCS.Test where

import Data.VCS.Ignore ( Git, Repo(..), listRepo )

example :: IO [FilePath]
example = do
  repo <- scanRepo @Git "path/to/repo"
  listRepo repo

2.2. Walking files/directories ignored by VCS

{-# LANGUAGE TypeApplications #-}

module Data.VCS.Test where

import Data.Maybe       ( catMaybes )
import System.Directory ( doesFileExist )
import Data.VCS.Ignore  ( Git, Repo(..), walkRepo )

onlyFiles :: IO [FilePath]
onlyFiles = do
  repo <- scanRepo @Git "path/to/repo"
  catMaybes <$> walkRepo repo walkFn
 where
  walkFn path = do
    file <- doesFileExist path
    pure (if file then Just path else Nothing)

2.3. Checking if path is ignored by VCS

{-# LANGUAGE TypeApplications #-}

module Data.VCS.Test where

import Data.VCS.Ignore ( Git, Repo(..) )

checkIgnored :: IO Bool
checkIgnored = do
  repo <- scanRepo @Git "path/to/repo"
  isIgnored repo "/some/path/.DS_Store"

3. Use as Executable

While vcs-ignore is mainly intended to be used as a library, it also comes with small executable called ignore that can be used standalone to verify whether given path is ignored or not.

$ ignore --help
vcs-ignore, v0.0.2.0 :: https://github.com/vaclavsvejcar/vcs-ignore

Usage: ignore (-p|--path PATH) [--debug] [-v|--version] [--numeric-version]
  library for handling files ignored by VCS systems

Available options:
  -p,--path PATH           path to check
  --debug                  produce more verbose output
  -v,--version             show version info
  --numeric-version        show only version number
  -h,--help                Show this help text

3.1. Checking if path is ignored by VCS

To verify if path is ignored by VCS, just call the ignore executable with -p parameter inside the VCS repository like this:

$ ignore -p .stack-work/some-file
Found repository at: /path/to/repo
Path '.stack-work/some-file' IS NOT ignored

$ echo $?
1

As you can see, ignore executable prints result in human readable form as well as it sets the exit code to 1 if the file is not ignored.