Documentation

Horde_Vcs_Git extends Horde_Vcs_Base
in package

Horde_Vcs_Git implementation.

Constructor args:

'sourceroot': The source root for this repository
'paths': Hash with the locations of all necessary binaries: 'git'
Tags
TODO

find bad output earlier - use proc_open, check stderr or result codes?

Copyright 2008-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

author

Chuck Hagenbuch chuck@horde.org

author

Michael Slusarz slusarz@horde.org

Table of Contents

$sourceroot  : string
The source root of the repository.
$version  : string
The git version
$_branchlist  : array<string|int, mixed>
The list of branches for the repo.
$_cache  : Horde_Cache
If caching is desired, a Horde_Cache object.
$_cacheVersion  : int
Current cache version.
$_diffTypes  : array<string|int, mixed>
The available diff types.
$_driver  : string
The current driver.
$_features  : array<string|int, mixed>
Driver features.
$_paths  : array<string|int, mixed>
Hash with the locations of all necessary binaries.
$_users  : array<string|int, mixed>
Hash caching the parsed users file.
__construct()  : mixed
Constructor.
abbrev()  : string
Returns an abbreviated form of the revision, for display.
annotate()  : mixed
TODO
assertValidRevision()  : mixed
Throw an exception if the revision number isn't valid.
availableDiffTypes()  : array<string|int, mixed>
Return the list of available diff types.
checkout()  : resource
Function which returns a file pointing to the head of the requested revision of a file.
cmp()  : int
Given two revisions, this figures out which one is greater than the the other.
diff()  : string
Obtain the differences between two revisions of a file.
getBranchList()  : mixed
TODO
getCommand()  : mixed
TODO
getDefaultBranch()  : mixed
getDirectory()  : Horde_Vcs_Directory_Base
Returns a directory object.
getFile()  : mixed
TODO
getPatchset()  : Horde_Vcs_Patchset
TODO
getPath()  : bool|string
Returns the location of the specified binary.
getRevisionRange()  : array<string|int, mixed>
Create a range of revisions between two revision numbers.
getUsers()  : array<string|int, mixed>
Parse the users file, if present in the sourceroot, and return a hash containing the requisite information, keyed on the username, and with the 'desc', 'name', and 'mail' values inside.
hasFeature()  : bool
Does this driver support the given feature?
isFile()  : mixed
TODO
isValidRevision()  : bool
TODO
popen()  : resource
Wrapper around popen() for locale-safe results.
runCommand()  : mixed
Runs a git commands.
_diff()  : string
Obtain the differences between two revisions of a file.
_getRevisionRange()  : mixed
TODO
_humanReadableDiff()  : array<string|int, mixed>
Obtain a tree containing information about the changes between two revisions.

Properties

$sourceroot

The source root of the repository.

public string $sourceroot

$version

The git version

public string $version

$_branchlist

The list of branches for the repo.

protected array<string|int, mixed> $_branchlist

$_cache

If caching is desired, a Horde_Cache object.

protected Horde_Cache $_cache

$_cacheVersion

Current cache version.

protected int $_cacheVersion = 5

$_diffTypes

The available diff types.

protected array<string|int, mixed> $_diffTypes = array('unified')

$_driver

The current driver.

protected string $_driver = 'Git'

$_features

Driver features.

protected array<string|int, mixed> $_features = array('deleted' => \false, 'patchsets' => \true, 'branches' => \true, 'snapshots' => \true)

$_paths

Hash with the locations of all necessary binaries.

protected array<string|int, mixed> $_paths = array()

$_users

Hash caching the parsed users file.

protected array<string|int, mixed> $_users = array()

Methods

__construct()

Constructor.

public __construct([mixed $params = array() ]) : mixed
Parameters
$params : mixed = array()
Tags
throws
Horde_Vcs_Exception
Return values
mixed

abbrev()

Returns an abbreviated form of the revision, for display.

public abbrev(string $rev) : string
Parameters
$rev : string

The revision string.

Return values
string

The abbreviated string.

annotate()

TODO

public annotate(mixed $fileob, mixed $rev) : mixed
Parameters
$fileob : mixed
$rev : mixed
Tags
throws
Horde_Vcs_Exception
Return values
mixed

assertValidRevision()

Throw an exception if the revision number isn't valid.

public assertValidRevision(mixed $rev) : mixed
Parameters
$rev : mixed

The revision number.

Tags
throws
Horde_Vcs_Exception
Return values
mixed

availableDiffTypes()

Return the list of available diff types.

public availableDiffTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

The list of available diff types for use with get().

checkout()

Function which returns a file pointing to the head of the requested revision of a file.

public checkout(mixed $file, string $rev) : resource
Parameters
$file : mixed
$rev : string

Revision number to check out

Tags
throws
Horde_Vcs_Exception
Return values
resource

A stream pointer to the head of the checkout.

cmp()

Given two revisions, this figures out which one is greater than the the other.

public cmp(string $rev1, string $rev2) : int
Parameters
$rev1 : string

Revision string.

$rev2 : string

Second revision string.

Return values
int

1 if the first is greater, -1 if the second if greater, and 0 if they are equal

diff()

Obtain the differences between two revisions of a file.

public diff(Horde_Vcs_File_Base $file, string $rev1, string $rev2[, array<string|int, mixed> $opts = array() ]) : string
Parameters
$file : Horde_Vcs_File_Base

The desired file.

$rev1 : string

Original revision number to compare from.

$rev2 : string

New revision number to compare against.

$opts : array<string|int, mixed> = array()

The following optional options:

  • 'human': (boolean) DEFAULT: false
  • 'num': (integer) DEFAULT: 3
  • 'type': (string) DEFAULT: 'unified'
  • 'ws': (boolean) DEFAULT: true
Tags
throws
Horde_Vcs_Exception
Return values
string

The diff string.

getBranchList()

TODO

public getBranchList() : mixed
Return values
mixed

getCommand()

TODO

public getCommand() : mixed
Return values
mixed

getDefaultBranch()

public getDefaultBranch() : mixed
Tags
TODO

?

Return values
mixed

getDirectory()

Returns a directory object.

public getDirectory(string $where[, array<string|int, mixed> $opts = array() ]) : Horde_Vcs_Directory_Base
Parameters
$where : string

Path to the directory.

$opts : array<string|int, mixed> = array()

Any additional options (depends on driver):

  • 'showattic': (boolean) Parse any Attic/ sub-directory contents too.
  • 'rev': (string) Generate directory list for a certain branch or revision.
Return values
Horde_Vcs_Directory_Base

A directory object.

getFile()

TODO

public getFile(mixed $filename[, mixed $opts = array() ]) : mixed

$opts: 'branch' - (string)

Parameters
$filename : mixed
$opts : mixed = array()
Return values
mixed

getPatchset()

TODO

public getPatchset([array<string|int, mixed> $opts = array() ]) : Horde_Vcs_Patchset
Parameters
$opts : array<string|int, mixed> = array()

Options:

  • 'file': (string) The filename to process. REQUIRED for this driver.
  • 'range': (array) The patchsets to process. DEFAULT: None (all patchsets are processed).
  • 'timezone': (string) The current timezone.
Return values
Horde_Vcs_Patchset

Patchset object.

getPath()

Returns the location of the specified binary.

public getPath(string $binary) : bool|string
Parameters
$binary : string

An external program name.

Return values
bool|string

The location of the external program or false if it wasn't specified.

getRevisionRange()

Create a range of revisions between two revision numbers.

public getRevisionRange(Horde_Vcs_File_Git $file, string $r1, string $r2) : array<string|int, mixed>
Parameters
$file : Horde_Vcs_File_Git

The desired file.

$r1 : string

The initial revision.

$r2 : string

The ending revision.

Return values
array<string|int, mixed>

The revision range, or empty if there is no straight line path between the revisions.

getUsers()

Parse the users file, if present in the sourceroot, and return a hash containing the requisite information, keyed on the username, and with the 'desc', 'name', and 'mail' values inside.

public getUsers(mixed $usersfile) : array<string|int, mixed>
Parameters
$usersfile : mixed
Tags
throws
Horde_Vcs_Exception
Return values
array<string|int, mixed>

User data.

hasFeature()

Does this driver support the given feature?

public hasFeature(mixed $feature) : bool
Parameters
$feature : mixed
Return values
bool

True if driver supports the given feature.

isFile()

TODO

public isFile(mixed $where[, mixed $branch = null ]) : mixed
Parameters
$where : mixed
$branch : mixed = null
Return values
mixed

isValidRevision()

TODO

public isValidRevision(mixed $rev) : bool
Parameters
$rev : mixed

The purported revision string.

Return values
bool

True if a valid revision string.

popen()

Wrapper around popen() for locale-safe results.

public popen(string $cmd[, string $mode = 'r' ]) : resource
Parameters
$cmd : string

Command to call.

$mode : string = 'r'

popen() mode.

Return values
resource

Pipe handle.

runCommand()

Runs a git commands.

public runCommand(string $args) : mixed

Uses proc_open() to properly catch errors and returns a stream with the command result. fclose() must be called manually on the returned stream and proc_close() on the resource, once the output stream has been finished reading.

Parameters
$args : string

Any arguments for the git command. Must be escaped.

Tags
throws
Horde_Vcs_Exception

if command cannot be executed or returns an error.

Return values
mixed

_diff()

Obtain the differences between two revisions of a file.

protected _diff(Horde_Vcs_File_Git $file, string $rev1, string $rev2, array<string|int, mixed> $opts) : string
Parameters
$file : Horde_Vcs_File_Git

The desired file.

$rev1 : string

Original revision number to compare from.

$rev2 : string

New revision number to compare against.

$opts : array<string|int, mixed>

The following optional options:

  • 'num': (integer) DEFAULT: 3
  • 'type': (string) DEFAULT: 'unified'
  • 'ws': (boolean) DEFAULT: true
Return values
string

The diff text.

_humanReadableDiff()

Obtain a tree containing information about the changes between two revisions.

protected _humanReadableDiff(array<string|int, mixed> $raw) : array<string|int, mixed>
Parameters
$raw : array<string|int, mixed>

An array of lines of the raw unified diff, normally obtained through Horde_Vcs_Diff::get().

Return values
array<string|int, mixed>

@TODO

Search results