vcswrapper-0.1.5: Wrapper for source code management systems

Safe HaskellNone
LanguageHaskell98

VCSWrapper.Git

Description

Provides high-level Git functions like commit, checkout, status, log,...

All functions of this module run in the Ctx monad, common to all VCS. On unexpected behavior, these functions will throw a VCSException.

Synopsis

Documentation

initDB #

Arguments

:: Bool

if True, this repository will be initialized as a bare repository (appends --bare to the git command)

-> Ctx () 

Initialize a new git repository. Executes git init.

add #

Arguments

:: [FilePath]

FilePaths to add to the index.

-> Ctx () 

Add files to the index. Executes git add.

rm #

Arguments

:: [FilePath]

FilePaths to remove.

-> Ctx () 

Remove files from the index and the working directory. Executes git rm.

commit #

Arguments

:: [FilePath]

FilePaths to be commited instead of the current index. Leave empty to commit the index.

-> Maybe (Text, Text)

(Author name, email)

-> Text

Commit message. Don't leave this empty.

-> [Text]

Options to be passed to the git executable.

-> Ctx () 

Commit the current index or the specified files to the repository. Executes git commit.

checkout #

Arguments

:: Maybe Text

Commit ID

-> Maybe Text

Branchname. If specified, git checkout -b <branchname> will be executed.

-> Ctx () 

Checkout the index to some commit ID. Executes git checkout.

status :: Ctx [Status] #

Return status of the repository as a list of Status. Executes git status.

simpleLog #

Arguments

:: Maybe Text

The branch from which to get the commit messages. (If Nothing, the current branch will be used).

-> Ctx [LogEntry] 

Get all commit messages. Executes git log.

localBranches #

Arguments

:: Ctx (Text, [Text])

(currently checked out branch, list of all other branches)

Get all local branches. Executes git branch.

revparse #

Arguments

:: Text

Revision to pass to rev-parse.

-> Ctx Text 

Rev-parse a revision. Executes git rev-parse.

remote :: Ctx [Text] #

Get all remotes. Executes git remote.

pull :: Ctx (Either Text ()) #

Pull changes from the remote as configured in the git configuration. If a merge conflict is detected, the error message is returned, otherwise 'Right ()' is returned. Executes git pull.

push :: Ctx () #

Push changes to the remote as configured in the git configuration. Executes git push.

runVcs #

Arguments

:: Config

Config for a VCS

-> Ctx t

An operation running in Ctx

-> IO t 

Run a VCS Ctx from a Config and returns the result

data VCSType #

Available VCS types implemented in this package.

Constructors

SVN 
GIT 
Mercurial 

type IsLocked = Bool #

True, if this file is locked by the VCS.

data LogEntry #

Represents a log entry in the history managed by the VCS.

Constructors

LogEntry 

Fields

Instances

newtype Ctx a #

Context for all VCS commands.

E.g. to create a new Git repository use something like this:

import VCSWrapper.Git
myInitRepoFn = do
    let config = makeConfig "path/to/repo" Nothing Nothing
    runVcs config $ initDB False

Constructors

Ctx (ReaderT Config IO a) 

Instances

Monad Ctx # 

Methods

(>>=) :: Ctx a -> (a -> Ctx b) -> Ctx b #

(>>) :: Ctx a -> Ctx b -> Ctx b #

return :: a -> Ctx a #

fail :: String -> Ctx a #

Functor Ctx # 

Methods

fmap :: (a -> b) -> Ctx a -> Ctx b #

(<$) :: a -> Ctx b -> Ctx a #

Applicative Ctx # 

Methods

pure :: a -> Ctx a #

(<*>) :: Ctx (a -> b) -> Ctx a -> Ctx b #

(*>) :: Ctx a -> Ctx b -> Ctx b #

(<*) :: Ctx a -> Ctx b -> Ctx a #

MonadIO Ctx # 

Methods

liftIO :: IO a -> Ctx a #

MonadReader Config Ctx # 

Methods

ask :: Ctx Config #

local :: (Config -> Config) -> Ctx a -> Ctx a #

reader :: (Config -> a) -> Ctx a #

data Config #

Configuration of the Ctx the VCS commands will be executed in.

Constructors

Config 

Fields

  • configCwd :: Maybe FilePath

    Path to the main directory of the repository. E.g. for Git: the directory of the repository containing the .git config directory.

  • configPath :: Maybe FilePath

    Path to the vcs executable. If Nothing, the PATH environment variable will be search for a matching executable.

  • configAuthor :: Maybe Author

    Author to be used for different VCS actions. If Nothing, the default for the selected repository will be used.

  • configEnvironment :: [(Text, Text)]

    List of environment variables mappings passed to the underlying VCS executable.

data Author #

Author to be passed to VCS commands where applicable.

Constructors

Author 

Fields

data VCSException #

This Exception-type will be thrown if a VCS command fails unexpectedly.

Constructors

VCSException Int Text Text FilePath [Text]

Exit code -> stdout -> errout -> configCwd of the Config -> List containing the executed command and its options

data Status #

Status of a file managed by the respective VCS.

data Modification #

Flags to describe the state of a file.

Constructors

None

File hasn't been modified.

Added

File has been selected to be managed by the respective VCS.

Conflicting

File is in conflicting state. Manually resolving the conflict may be necessary.

Deleted

File has been deleted.

Modified

File has been modified since last commit.

Replaced

File has been replaced by a different file.

Untracked

File is currently not known by the VCS.

Unknown

State of file is unknown.

Ignored

File is ignored by VCS.

Missing

File is missing.

makeConfig #

Arguments

:: Maybe FilePath

Path to the main directory of the repository. E.g. for Git: the directory of the repository containing the .git config directory.

-> Maybe FilePath

Path to the vcs executable. If Nothing, the PATH environment variable will be search for a matching executable.

-> Maybe Author

Author to be used for different VCS actions. If Nothing, the default for the selected repository will be used.

-> Config 

Creates a new Config.

makeConfigWithEnvironment #

Arguments

:: Maybe FilePath

Path to the main directory of the repository. E.g. for Git: the directory of the repository containing the .git config directory.

-> Maybe FilePath

Path to the vcs executable. If Nothing, the PATH environment variable will be search for a matching executable.

-> Maybe Author

Author to be used for different VCS actions. If Nothing, the default for the selected repository will be used.

-> [(Text, Text)]

List of environment variables mappings passed to the underlying VCS executable.

-> Config 

Creates a new Config with a list of environment variables.

filePath :: Status -> FilePath #

Retrieve the FilePath of any VCS Status.

modification :: Status -> Modification #

Retrieve the Modification of any VCS Status.

isLocked :: Status -> IsLocked #

Retrieve the IsLocked of any VCS Status. For Git, this returns always False.