PHP Class Gitonomy\Git\Repository

Main entry point for browsing a Git repository.
Author: Alexandre Salomé ([email protected])
Afficher le fichier Open project: gitonomy/gitlib Class Usage Examples

Protected Properties

Свойство Type Description
$command Path to git command.
$debug boolean Debug flag, indicating if errors should be thrown.
$environmentVariables array Environment variables that should be set for every running process.
$gitDir string Directory containing git files.
$logger Psr\Log\LoggerInterface Logger (can be null).
$objects array Associative array, indexed by object hash
$processTimeout integer Timeout that should be set for every running process.
$referenceBag Gitonomy\Git\ReferenceBag Reference bag associated to this repository.
$workingDir string Working directory.

Méthodes publiques

Méthode Description
__construct ( string $dir, array $options = [] ) Constructs a new repository.
cloneTo ( string $path, boolean $bare = true, array $options = [] ) : Repository Clones the current repository to a new directory and return instance of new repository.
getBlame ( $revision, $file, $lineRange = null )
getBlob ( string $hash ) : Gitonomy\Git\Blob Instanciates a blob object or fetches one from the cache.
getCommit ( string $hash ) : Gitonomy\Git\Commit Instanciates a commit object or fetches one from the cache.
getDescription ( ) : string Returns description of repository from description file in git directory.
getDiff ( $revisions ) : Gitonomy\Git\Diff\Diff
getGitDir ( ) : string Returns the directory containing git files (git-dir).
getHead ( ) : Gitonomy\Git\Reference | Gitonomy\Git\Commit | null
getHeadCommit ( ) : Gitonomy\Git\Commit | null Returns the HEAD resolved as a commit.
getHooks ( ) : Gitonomy\Git\Hooks Returns the hooks object.
getLog ( array $revisions = null, array $paths = null, integer $offset = null, integer $limit = null ) : Gitonomy\Git\Log Returns log for a given set of revisions and paths.
getLogger ( ) : Psr\Log\LoggerInterface Returns repository logger.
getPath ( ) : string Returns the path to the git repository.
getReferences ( ) : Gitonomy\Git\ReferenceBag Returns the reference list associated to the repository.
getRevision ( string $name ) : Gitonomy\Git\Revision Instanciates a revision.
getSize ( ) : integer Returns the size of repository, in kilobytes.
getTree ( string $hash ) : Gitonomy\Git\Tree Instanciates a tree object or fetches one from the cache.
getWorkingCopy ( ) : Gitonomy\Git\WorkingCopy
getWorkingDir ( ) : string Returns the work-tree directory. This may be null if repository is bare.
hasDescription ( ) : boolean Tests if repository has a custom set description.
isBare ( ) : boolean Tests if repository is a bare repository.
isHeadAttached ( ) : boolean
isHeadDetached ( ) : boolean
run ( string $command, array $args = [] ) : string This command is a facility command. You can run any command directly on git repository.
setDescription ( $description ) : Repository Changes the repository description (file description in git-directory).
setLogger ( Psr\Log\LoggerInterface $logger ) : Repository Set repository logger.
shell ( string $command, array $env = [] ) Executes a shell command on the repository, using PHP pipes.

Private Methods

Méthode Description
getProcess ( $command, $args = [] ) This internal method is used to create a process object.
initDir ( string $gitDir, string $workingDir = null ) Initializes directory attributes on repository:.

Method Details

__construct() public méthode

Available options are: * working_dir : specify where working copy is located (option --work-tree) * debug : (default: true) enable/disable minimize errors and reduce log level * logger : a logger to use for logging actions (Psr\Log\LoggerInterface) * environment_variables : define environment variables for every ran process
public __construct ( string $dir, array $options = [] )
$dir string path to git repository
$options array array of options values

cloneTo() public méthode

Clones the current repository to a new directory and return instance of new repository.
public cloneTo ( string $path, boolean $bare = true, array $options = [] ) : Repository
$path string path to the new repository in which current repository will be cloned
$bare boolean flag indicating if repository is bare or has a working-copy
$options array
Résultat Repository the newly created repository

getBlame() public méthode

public getBlame ( $revision, $file, $lineRange = null )

getBlob() public méthode

Instanciates a blob object or fetches one from the cache.
public getBlob ( string $hash ) : Gitonomy\Git\Blob
$hash string A blob hash, with a length of 40
Résultat Gitonomy\Git\Blob

getCommit() public méthode

Instanciates a commit object or fetches one from the cache.
public getCommit ( string $hash ) : Gitonomy\Git\Commit
$hash string A commit hash, with a length of 40
Résultat Gitonomy\Git\Commit

getDescription() public méthode

Returns description of repository from description file in git directory.
public getDescription ( ) : string
Résultat string The description

getDiff() public méthode

public getDiff ( $revisions ) : Gitonomy\Git\Diff\Diff
Résultat Gitonomy\Git\Diff\Diff

getGitDir() public méthode

Returns the directory containing git files (git-dir).
public getGitDir ( ) : string
Résultat string

getHead() public méthode

public getHead ( ) : Gitonomy\Git\Reference | Gitonomy\Git\Commit | null
Résultat Gitonomy\Git\Reference | Gitonomy\Git\Commit | null current HEAD object or null if error occurs

getHeadCommit() public méthode

Returns the HEAD resolved as a commit.
public getHeadCommit ( ) : Gitonomy\Git\Commit | null
Résultat Gitonomy\Git\Commit | null returns a Commit or ``null`` if repository is empty

getHooks() public méthode

Returns the hooks object.
public getHooks ( ) : Gitonomy\Git\Hooks
Résultat Gitonomy\Git\Hooks

getLog() public méthode

All those values can be null, meaning everything.
public getLog ( array $revisions = null, array $paths = null, integer $offset = null, integer $limit = null ) : Gitonomy\Git\Log
$revisions array An array of revisions to show logs from. Can be any text value type
$paths array Restrict log to modifications occurring on given paths.
$offset integer Start from a given offset in results.
$limit integer Limit number of total results.
Résultat Gitonomy\Git\Log

getLogger() public méthode

Returns repository logger.
public getLogger ( ) : Psr\Log\LoggerInterface
Résultat Psr\Log\LoggerInterface the logger or null

getPath() public méthode

Returns the path to the git repository.
public getPath ( ) : string
Résultat string A directory path

getReferences() public méthode

Returns the reference list associated to the repository.
public getReferences ( ) : Gitonomy\Git\ReferenceBag
Résultat Gitonomy\Git\ReferenceBag

getRevision() public méthode

Instanciates a revision.
public getRevision ( string $name ) : Gitonomy\Git\Revision
$name string Name of the revision
Résultat Gitonomy\Git\Revision

getSize() public méthode

Returns the size of repository, in kilobytes.
public getSize ( ) : integer
Résultat integer A sum, in kilobytes

getTree() public méthode

Instanciates a tree object or fetches one from the cache.
public getTree ( string $hash ) : Gitonomy\Git\Tree
$hash string A tree hash, with a length of 40
Résultat Gitonomy\Git\Tree

getWorkingCopy() public méthode

public getWorkingCopy ( ) : Gitonomy\Git\WorkingCopy
Résultat Gitonomy\Git\WorkingCopy

getWorkingDir() public méthode

Returns the work-tree directory. This may be null if repository is bare.
public getWorkingDir ( ) : string
Résultat string path to repository or null if repository is bare

hasDescription() public méthode

Tests if repository has a custom set description.
public hasDescription ( ) : boolean
Résultat boolean

isBare() public méthode

Tests if repository is a bare repository.
public isBare ( ) : boolean
Résultat boolean

isHeadAttached() public méthode

public isHeadAttached ( ) : boolean
Résultat boolean

isHeadDetached() public méthode

public isHeadDetached ( ) : boolean
Résultat boolean

run() public méthode

This command is a facility command. You can run any command directly on git repository.
public run ( string $command, array $args = [] ) : string
$command string Git command to run (checkout, branch, tag)
$args array Arguments of git command
Résultat string Output of a successful process or null if execution failed and debug-mode is disabled.

setDescription() public méthode

Changes the repository description (file description in git-directory).
public setDescription ( $description ) : Repository
Résultat Repository the current repository

setLogger() public méthode

Set repository logger.
public setLogger ( Psr\Log\LoggerInterface $logger ) : Repository
$logger Psr\Log\LoggerInterface A logger
Résultat Repository The current repository

shell() public méthode

Executes a shell command on the repository, using PHP pipes.
public shell ( string $command, array $env = [] )
$command string The command to execute
$env array

Property Details

$command protected_oe property

Path to git command.
protected $command

$debug protected_oe property

Debug flag, indicating if errors should be thrown.
protected bool $debug
Résultat boolean

$environmentVariables protected_oe property

Environment variables that should be set for every running process.
protected array $environmentVariables
Résultat array

$gitDir protected_oe property

Directory containing git files.
protected string $gitDir
Résultat string

$logger protected_oe property

Logger (can be null).
protected LoggerInterface,Psr\Log $logger
Résultat Psr\Log\LoggerInterface

$objects protected_oe property

Associative array, indexed by object hash
protected array $objects
Résultat array

$processTimeout protected_oe property

Timeout that should be set for every running process.
protected int $processTimeout
Résultat integer

$referenceBag protected_oe property

Reference bag associated to this repository.
protected ReferenceBag,Gitonomy\Git $referenceBag
Résultat Gitonomy\Git\ReferenceBag

$workingDir protected_oe property

Working directory.
protected string $workingDir
Résultat string