cli-utils-4.1.0
LicenseBSD3
Maintainertbidne@gmail.com
Safe HaskellNone
LanguageHaskell2010

Git.Stale.Core.Internal

Description

Exports utility functions mainly for parsing/transforming between types/errors.

Synopsis

Documentation

badBranch :: Text -> Bool Source #

Tests for bad branches based on presence of * and >.

exceptToErr :: Show a => Either a (Either Err b) -> Either Err b Source #

Joins nested Eithers.

parseLog :: NameLog -> ErrOr NameAuthDay Source #

Parses NameLog into NameAuthDay, recording errors as ErrOr.

parseAuthDateStr :: NameLog -> ErrOr NameAuthDateStr Source #

Intermediate parsing of NameLog into NameAuthDateStr, recording errors as ErrOr.

parseDay :: NameAuthDateStr -> ErrOr NameAuthDay Source #

Intermediate parsing of NameAuthDateStr into NameAuthDay, recording errors as ErrOr.

safeRead :: Text -> ErrOr Int Source #

Safely reads Text into ErrOr Int.

stale :: RNonNegative Int -> Day -> NameAuthDay -> Bool Source #

Determines if NameAuthDay is stale given by

stale lim day (_, _, d) <=> day - d >= lim

staleNonErr :: RNonNegative Int -> Day -> ErrOr NameAuthDay -> Bool Source #

For Right NameAuthDay, behaves the same as stale. But for Left Err it is always true, since we do not want to filter out errors.

textToName :: Text -> ErrOr Name Source #

Strips whitespace and potential git prefix (i.e. remotes/). Works for strings with no prefix and those that have the prefix exactly once, e.g.

textToName "branch" -> branch
textToName "remotes/origin/branch" -> origin/branch
textToName "blah/remotes/origin/branch" -> origin/branch

Returns Left ParseName if the prefix occurs more than once as we have definitely entered undefined territory.

unsafeToInt :: Text -> Int Source #

Unsafely reads Text to Int.