PHP Класс Gitonomy\Git\Repository

Main entry point for browsing a Git repository.
Автор: Alexandre Salomé ([email protected])
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$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.

Открытые методы

Метод Описание
__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.

Приватные методы

Метод Описание
getProcess ( $command, $args = [] ) This internal method is used to create a process object.
initDir ( string $gitDir, string $workingDir = null ) Initializes directory attributes on repository:.

Описание методов

__construct() публичный Метод

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() публичный Метод

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
Результат Repository the newly created repository

getBlame() публичный Метод

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

getBlob() публичный Метод

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
Результат Gitonomy\Git\Blob

getCommit() публичный Метод

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
Результат Gitonomy\Git\Commit

getDescription() публичный Метод

Returns description of repository from description file in git directory.
public getDescription ( ) : string
Результат string The description

getDiff() публичный Метод

public getDiff ( $revisions ) : Gitonomy\Git\Diff\Diff
Результат Gitonomy\Git\Diff\Diff

getGitDir() публичный Метод

Returns the directory containing git files (git-dir).
public getGitDir ( ) : string
Результат string

getHead() публичный Метод

public getHead ( ) : Gitonomy\Git\Reference | Gitonomy\Git\Commit | null
Результат Gitonomy\Git\Reference | Gitonomy\Git\Commit | null current HEAD object or null if error occurs

getHeadCommit() публичный Метод

Returns the HEAD resolved as a commit.
public getHeadCommit ( ) : Gitonomy\Git\Commit | null
Результат Gitonomy\Git\Commit | null returns a Commit or ``null`` if repository is empty

getHooks() публичный Метод

Returns the hooks object.
public getHooks ( ) : Gitonomy\Git\Hooks
Результат Gitonomy\Git\Hooks

getLog() публичный Метод

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.
Результат Gitonomy\Git\Log

getLogger() публичный Метод

Returns repository logger.
public getLogger ( ) : Psr\Log\LoggerInterface
Результат Psr\Log\LoggerInterface the logger or null

getPath() публичный Метод

Returns the path to the git repository.
public getPath ( ) : string
Результат string A directory path

getReferences() публичный Метод

Returns the reference list associated to the repository.
public getReferences ( ) : Gitonomy\Git\ReferenceBag
Результат Gitonomy\Git\ReferenceBag

getRevision() публичный Метод

Instanciates a revision.
public getRevision ( string $name ) : Gitonomy\Git\Revision
$name string Name of the revision
Результат Gitonomy\Git\Revision

getSize() публичный Метод

Returns the size of repository, in kilobytes.
public getSize ( ) : integer
Результат integer A sum, in kilobytes

getTree() публичный Метод

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
Результат Gitonomy\Git\Tree

getWorkingCopy() публичный Метод

public getWorkingCopy ( ) : Gitonomy\Git\WorkingCopy
Результат Gitonomy\Git\WorkingCopy

getWorkingDir() публичный Метод

Returns the work-tree directory. This may be null if repository is bare.
public getWorkingDir ( ) : string
Результат string path to repository or null if repository is bare

hasDescription() публичный Метод

Tests if repository has a custom set description.
public hasDescription ( ) : boolean
Результат boolean

isBare() публичный Метод

Tests if repository is a bare repository.
public isBare ( ) : boolean
Результат boolean

isHeadAttached() публичный Метод

public isHeadAttached ( ) : boolean
Результат boolean

isHeadDetached() публичный Метод

public isHeadDetached ( ) : boolean
Результат boolean

run() публичный Метод

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
Результат string Output of a successful process or null if execution failed and debug-mode is disabled.

setDescription() публичный Метод

Changes the repository description (file description in git-directory).
public setDescription ( $description ) : Repository
Результат Repository the current repository

setLogger() публичный Метод

Set repository logger.
public setLogger ( Psr\Log\LoggerInterface $logger ) : Repository
$logger Psr\Log\LoggerInterface A logger
Результат Repository The current repository

shell() публичный Метод

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

Описание свойств

$command защищенное свойство

Path to git command.
protected $command

$debug защищенное свойство

Debug flag, indicating if errors should be thrown.
protected bool $debug
Результат boolean

$environmentVariables защищенное свойство

Environment variables that should be set for every running process.
protected array $environmentVariables
Результат array

$gitDir защищенное свойство

Directory containing git files.
protected string $gitDir
Результат string

$logger защищенное свойство

Logger (can be null).
protected LoggerInterface,Psr\Log $logger
Результат Psr\Log\LoggerInterface

$objects защищенное свойство

Associative array, indexed by object hash
protected array $objects
Результат array

$processTimeout защищенное свойство

Timeout that should be set for every running process.
protected int $processTimeout
Результат integer

$referenceBag защищенное свойство

Reference bag associated to this repository.
protected ReferenceBag,Gitonomy\Git $referenceBag
Результат Gitonomy\Git\ReferenceBag

$workingDir защищенное свойство

Working directory.
protected string $workingDir
Результат string