Git4s

com.geirolz.git4s.Git4s
See theGit4s companion object
sealed trait Git4s[F[_]] extends GitInstaller[F], Git4sRepository[F]

Git4s is a pure functional wrapper around the git command line.

It provides a set of methods to interact with a git.

You can create a Git4s instance using the apply method.

Logging is done using the CmdLogger type class implicitly passed to each method. You can provide your own implementation of CmdLogger to log the command output as you like, or use the default one provided by the library. By default, the library uses the Noop logger which doesn't log anything since usually these logs are useful just for debugging purpose.

Example:

import cats.effect.IO
import com.geirolz.git4s.Git4s
import com.geirolz.git4s.data.GitVersion
import com.geirolz.git4s.log.*

given logger: CmdLogger[IO] = CmdLogger.console[IO](LogFilter.all)
val result: IO[GitVersion] = Git4s[IO].version

Type parameters

F

the effect type

Attributes

Companion
object
Graph
Supertypes
trait Git4sRepository[F]
trait GitInstaller[F]
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def clone(repository: String, directory: Path)(using CmdLogger[F]): F[Unit]

Clone a repository into a new directory.

Clone a repository into a new directory.

This method is not under Git4sRepository because it's not related to a specific repository.

https://git-scm.com/docs/git-clone

Attributes

Get a type to access Git global config

Get a type to access Git global config

Attributes

def help(using CmdLogger[F]): F[String]

Get the version of the installed git

Get the version of the installed git

https://git-scm.com/docs/git-version

Attributes

Get a type to access Git local config

Get a type to access Git local config

Attributes

Instruct Git4s to use the current working directory.

Instruct Git4s to use the current working directory.

Attributes

def withWorkingDirectory(dir: Path): Git4s[F]

Set the working directory for the Git4s instance.

Set the working directory for the Git4s instance.

Attributes

def workingDirectory: Option[Path]

Get the current working directory if set.

Get the current working directory if set.

None means current director.

Attributes

Concrete methods

inline def withWorkingDirectory(dir: String): Git4s[F]

Set the working directory for the Git4s instance.

Set the working directory for the Git4s instance.

Attributes

Inherited methods

def add(pattern: String)(using CmdLogger[F]): F[GitAddResult]

Add file contents to the index.

Add file contents to the index.

Interactive commands not supported yet.

https://git-scm.com/docs/git-add

Attributes

Inherited from:
Git4sRepository
def checkout(branchName: BranchName, createIfNotExists: Boolean): F[Unit]

Select the branch with the specified name

Select the branch with the specified name

Attributes

Inherited from:
Git4sRepository
def clean(force: Boolean, recursive: Boolean, dontUseStdIgnoreRules: Boolean)(using CmdLogger[F]): F[Unit]

Remove untracked files from the working tree.

Remove untracked files from the working tree.

https://git-scm.com/docs/git-clean

Attributes

Inherited from:
Git4sRepository
def commit(message: String, fixup: Option[FixupCommit])(using CmdLogger[F]): F[GitCommitResult]

Record changes to the repository.

Record changes to the repository.

https://git-scm.com/docs/git-commit

Attributes

Inherited from:
Git4sRepository
def currentBranch(using CmdLogger[F]): F[BranchName]

Show the current branch.

Show the current branch.

https://git-scm.com/docs/git-rev-parse

Attributes

Inherited from:
Git4sRepository
def deleteLocalBranch(branchName: BranchName): F[Unit]

Delete a branch.

Attributes

Inherited from:
Git4sRepository
def deleteRemoteBranch(branchName: BranchName, remote: Remote): F[Unit]

Delete a branch on the remote.

Delete a branch on the remote.

https://git-scm.com/docs/git-push

Attributes

Inherited from:
Git4sRepository
def diff(pattern: Option[String], added: Boolean, copied: Boolean, deleted: Boolean, modified: Boolean, renamed: Boolean, typeChanged: Boolean, unmerged: Boolean, unknown: Boolean, broken: Boolean, allOrNone: Boolean)(using CmdLogger[F]): Stream[F, FileDiff]

Show changes between commits, commit and working tree, etc

Show changes between commits, commit and working tree, etc

https://git-scm.com/docs/git-diff

Attributes

Inherited from:
Git4sRepository
def fetch(remote: Remote): F[Unit]

Download objects and refs from another repository.

Download objects and refs from another repository.

https://git-scm.com/docs/git-fetch

Attributes

Inherited from:
Git4sRepository
def init(using CmdLogger[F]): F[GitInitResult]

Create an empty Git repository or reinitialize an existing one.

Create an empty Git repository or reinitialize an existing one.

https://git-scm.com/docs/git-init

Attributes

Inherited from:
Git4sRepository
def install(using CmdLogger[F]): F[Unit]

Install git

Install git

Attributes

Inherited from:
GitInstaller
def installIfNeeded(using CmdLogger[F]): F[Boolean]

Install git if it's not already installed

Install git if it's not already installed

Attributes

Inherited from:
GitInstaller
def isInstalled(using CmdLogger[F]): F[Boolean]

Check if git is installed

Check if git is installed

Attributes

Inherited from:
GitInstaller
def pull(remote: Remote, targetBranch: Option[BranchName], rebase: Boolean, fastForwardOnly: Boolean, noFastForward: Boolean, squash: Boolean, noCommit: Boolean, noVerify: Boolean)(using CmdLogger[F]): F[Unit]

Fetch from and integrate with another repository or a local branch.

Fetch from and integrate with another repository or a local branch.

https://git-scm.com/docs/git-pull

Attributes

Inherited from:
Git4sRepository
def push(remote: Remote, sourceBranch: Option[BranchName], remoteTargetBranch: Option[BranchName], force: Boolean)(using CmdLogger[F]): F[Unit]

Update remote refs along with associated objects.

Update remote refs along with associated objects.

https://git-scm.com/docs/git-push

Attributes

Inherited from:
Git4sRepository
def reinstall(using CmdLogger[F]): F[Unit]

Uninstall git and then install it again

Uninstall git and then install it again

Attributes

Inherited from:
GitInstaller
def reset: Git4sReset[F]

Return a Git4sReset type to perform resets

Return a Git4sReset type to perform resets

Attributes

Inherited from:
Git4sRepository
def status(using CmdLogger[F]): F[GitStatus]

Show the working tree status.

Show the working tree status.

https://git-scm.com/docs/git-status

Attributes

Inherited from:
Git4sRepository
def uninstall(using CmdLogger[F]): F[Unit]

Uninstall git

Uninstall git

Attributes

Inherited from:
GitInstaller
def version(using CmdLogger[F]): F[GitVersion]

Get the installed git version

Get the installed git version

Attributes

Inherited from:
GitInstaller