vcs-ignore-0.0.1.0: Library for handling files ignored by VCS systems.
Copyright(c) 2020-2021 Vaclav Svejcar
LicenseBSD-3-Clause
Maintainervaclav.svejcar@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Data.VCS.Ignore.Repo.Git

Description

This module contains implementation of Repo type class for the GIT content versioning system. Most of the public functions is exported only to make them visible for tests, end user of this library really shouldn't need to use them.

Synopsis

Documentation

data Git Source #

Data type representing scanned instance of GIT repository.

Constructors

Git 

Fields

Instances

Instances details
Eq Git Source # 
Instance details

Defined in Data.VCS.Ignore.Repo.Git

Methods

(==) :: Git -> Git -> Bool #

(/=) :: Git -> Git -> Bool #

Show Git Source # 
Instance details

Defined in Data.VCS.Ignore.Repo.Git

Methods

showsPrec :: Int -> Git -> ShowS #

show :: Git -> String #

showList :: [Git] -> ShowS #

Repo Git Source # 
Instance details

Defined in Data.VCS.Ignore.Repo.Git

data Pattern Source #

Represents single pattern to be used as a rule for ignoring paths.

Constructors

Pattern 

Fields

Instances

Instances details
Eq Pattern Source # 
Instance details

Defined in Data.VCS.Ignore.Repo.Git

Methods

(==) :: Pattern -> Pattern -> Bool #

(/=) :: Pattern -> Pattern -> Bool #

Show Pattern Source # 
Instance details

Defined in Data.VCS.Ignore.Repo.Git

IsString Pattern Source # 
Instance details

Defined in Data.VCS.Ignore.Repo.Git

Methods

fromString :: String -> Pattern #

compilePattern Source #

Arguments

:: Text

raw pattern as text

-> Pattern

compiled pattern

Compiles pattern.

matchesPattern Source #

Arguments

:: Pattern

pattern to match against

-> FilePath

path to check

-> Bool

check result

Tests whether given path matches against the pattern.

parsePatterns Source #

Arguments

:: Text

text to parse

-> [Pattern]

parsed patterns

Parses Glob patterns from given text source. Each line in input text is considered to be single pattern. Lines starting with # (comments) and blank lines are skipped.

>>> parsePatterns "*.xml\n.DS_Store"
[Pattern {pPatterns = [compile "*.xml",compile "*.xml/*"], pRaw = "*.xml", pIsNegated = False},Pattern {pPatterns = [compile "**/.DS_Store",compile "**/.DS_Store/*"], pRaw = ".DS_Store", pIsNegated = False}]

loadPatterns Source #

Arguments

:: MonadIO m 
=> FilePath

path to text file to parse

-> m [Pattern]

parsed Glob patterns

Loads Glob patterns from given text file. If the fille cannot be read for any reason, empty list is returned. See parsePatterns for more details about parsing.

findGitIgnores Source #

Arguments

:: MonadIO m 
=> FilePath

path to the directory to search in

-> m [FilePath]

paths of found .gitignore files

Recursively finds all .gitignore files within the given directory path.

gitIgnorePatterns Source #

Arguments

:: MonadIO m 
=> FilePath

path to the directory to search .gitignore files in

-> m [(FilePath, [Pattern])]

list of .gitignore paths and parsed Glob patterns

Recursively finds all .gitignore files within the given directory path and parses them into Glob patterns. See loadPatterns and findGitIgnores for more details.

repoPatterns Source #

Arguments

:: MonadIO m 
=> FilePath

path to the GIT repository root

-> m [Pattern]

parsed Glob patterns

Loads GIT repository specific ignore patterns, present in REPO_ROOT/info/exclude file.

globalPatterns Source #

Arguments

:: MonadIO m 
=> m [Pattern]

parsed Glob patterns

Loads global GIT ignore patterns, present in XDG_CONFIG_GOME/git/ignore file.

scanRepo' Source #

Arguments

:: (MonadIO m, MonadThrow m) 
=> m [Pattern]

reference to globalPatterns function (or similar)

-> (FilePath -> m [Pattern])

reference to repoPatterns function (or similar)

-> (FilePath -> m [(FilePath, [Pattern])])

reference to gitIgnorePatterns function (or similar)

-> (FilePath -> m Bool)

reference to isGitRepo function (or similar)

-> FilePath

path to GIT repository root

-> m Git

scanned Git repository

Internal version of scanRepo, where individual functions needs to be explicitly provided, which is useful mainly for testing purposes.

isIgnored' Source #

Arguments

:: MonadIO m 
=> Git

scanned GIT repository

-> FilePath

path to check if ignored

-> m Bool 

Internal version of isIgnored function.

isGitRepo Source #

Arguments

:: MonadIO m 
=> FilePath

path to the directory to check

-> m Bool

True if the given directory is valid GIT repository

Checks whether given directory path is valid GIT repository.