PHP Класс GitWrapper\GitWorkingCopy

All commands executed via an instance of this class act on the working copy that is set through the constructor.
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$cloned If the variable is null, the a rudimentary check will be performed to see if the directory looks like it is a working copy.
$directory string Path to the directory containing the working copy.
$output string The output captured by the last run Git commnd(s).
$wrapper GitWrapper\GitWrapper The GitWrapper object that likely instantiated this class.

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

Метод Описание
__call ( $method, $args ) Hackish, allows us to use "clone" as a method name.
__construct ( gitwrapper\GitWrapper $wrapper, string $directory ) Constructs a GitWorkingCopy object.
__toString ( ) : string Gets the output captured by the last run Git commnd(s).
add ( string $filepattern, array $options = [] ) : GitWorkingCopy Executes a git add command.
addRemote ( string $name, string $url, array $options = [] ) : GitWorkingCopy Adds a remote to the repository.
apply ( ) : GitWorkingCopy Executes a git apply command.
archive ( ) : GitWorkingCopy Executes a git archive command.
bisect ( string $sub_command ) : GitWorkingCopy Executes a git bisect command.
branch ( ) : GitWorkingCopy Executes a git branch command.
checkout ( ) : GitWorkingCopy Executes a git checkout command.
checkoutNewBranch ( string $branch, array $options = [] ) Create a new branch and check it out.
clean ( ) : GitWorkingCopy Executes a git clean command.
clearOutput ( ) : GitWorkingCopy Clears the stored output captured by the last run Git command(s).
cloneRepository ( string $repository, array $options = [] ) : GitWorkingCopy Executes a git clone command.
commit ( ) : GitWorkingCopy Executes a git commit command.
config ( ) : GitWorkingCopy Executes a git config command.
diff ( ) : GitWorkingCopy Executes a git diff command.
fetch ( ) : GitWorkingCopy Executes a git fetch command.
fetchAll ( array $options = [] ) Fetches all remotes.
getBranches ( ) : gitwrapper\GitBranches Returns a GitBranches object containing information on the repository's branches.
getDirectory ( ) : string Gets the path to the directory containing the working copy.
getOutput ( ) : string Gets the output captured by the last run Git commnd(s).
getRemote ( string $name ) : array Returns the given remote.
getRemoteUrl ( string $remote, string $operation = 'fetch' ) : string Returns the fetch or push URL of a given remote.
getRemotes ( ) : array Returns all existing remotes.
getStatus ( ) : string Returns the output of a git status -s command.
getWrapper ( ) : GitWrapper\GitWrapper Returns the GitWrapper object that likely instantiated this class.
grep ( ) : GitWorkingCopy Executes a git grep command.
hasChanges ( ) : boolean Returns true if there are changes to commit.
hasRemote ( string $name ) : boolean Checks if the given remote exists.
init ( array $options = [] ) : GitWorkingCopy Executes a git init command.
isAhead ( ) : boolean Returns whether HEAD is ahead of its remote tracking branch.
isBehind ( ) : boolean Returns whether HEAD is behind its remote tracking branch.
isCloned ( ) : boolean Checks whether a repository has already been cloned to this directory.
isTracking ( ) : boolean Returns whether HEAD has a remote tracking branch.
isUpToDate ( ) : boolean Returns whether HEAD is up-to-date with its remote tracking branch.
log ( ) : GitWorkingCopy Executes a git log command.
merge ( ) : GitWorkingCopy Executes a git merge command.
mv ( string $source, string $destination, array $options = [] ) : GitWorkingCopy Executes a git mv command.
needsMerge ( ) : boolean Returns whether HEAD needs to be merged with its remote tracking branch.
pull ( ) : GitWorkingCopy Executes a git pull command.
push ( ) : GitWorkingCopy Executes a git push command.
pushTag ( string $tag, string $repository = 'origin', array $options = [] ) Helper method that pushes a tag to a repository.
pushTags ( string $repository = 'origin', array $options = [] ) Helper method that pushes all tags to a repository.
rebase ( ) : GitWorkingCopy Executes a git rebase command.
remote ( ) : GitWorkingCopy Executes a git remote command.
removeRemote ( string $name ) : GitWorkingCopy Removes the given remote.
reset ( ) : GitWorkingCopy Executes a git reset command.
rm ( string $filepattern, array $options = [] ) : GitWorkingCopy Executes a git rm command.
run ( array $args, boolean $setDirectory = true ) : GitWorkingCopy Runs a Git command and captures the output.
setCloned ( boolean $cloned ) : GitWorkingCopy Manually sets the cloned flag.
show ( string $object, array $options = [] ) : GitWorkingCopy Executes a git show command.
status ( ) : GitWorkingCopy Executes a git status command.
tag ( ) : GitWorkingCopy Executes a git tag command.

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

__call() публичный метод

$throws \BadMethodCallException
public __call ( $method, $args )

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

Constructs a GitWorkingCopy object.
public __construct ( gitwrapper\GitWrapper $wrapper, string $directory )
$wrapper gitwrapper\GitWrapper The GitWrapper object that likely instantiated this class.
$directory string Path to the directory containing the working copy.

__toString() публичный метод

Gets the output captured by the last run Git commnd(s).
См. также: GitWorkingCopy::getOutput()
public __toString ( ) : string
Результат string

add() публичный метод

Add file contents to the index.
public add ( string $filepattern, array $options = [] ) : GitWorkingCopy
$filepattern string Files to add content from. Fileglobs (e.g. *.c) can be given to add all matching files. Also a leading directory name (e.g. dir to add dir/file1 and dir/file2) can be given to add all files in the directory, recursively.
$options array An optional array of command line options.
Результат GitWorkingCopy

addRemote() публичный метод

Adds a remote to the repository.
public addRemote ( string $name, string $url, array $options = [] ) : GitWorkingCopy
$name string The name of the remote to add.
$url string The URL of the remote to add.
$options array An associative array of options, with the following keys: - -f: Boolean, set to true to run git fetch immediately after the remote is set up. Defaults to false. - --tags: Boolean. By default only the tags from the fetched branches are imported when git fetch is run. Set this to true to import every tag from the remote repository. Defaults to false. - --no-tags: Boolean, when set to true, git fetch does not import tags from the remote repository. Defaults to false. - -t: Optional array of branch names to track. If left empty, all branches will be tracked. - -m: Optional name of the master branch to track. This will set up a symbolic ref 'refs/remotes//HEAD which points at the specified master branch on the remote. When omitted, no symbolic ref will be created.
Результат GitWorkingCopy

apply() публичный метод

Apply a patch to files and/or to the index
public apply ( ) : GitWorkingCopy
Результат GitWorkingCopy

archive() публичный метод

Create an archive of files from a named tree
public archive ( ) : GitWorkingCopy
Результат GitWorkingCopy

bisect() публичный метод

Find by binary search the change that introduced a bug.
public bisect ( string $sub_command ) : GitWorkingCopy
$sub_command string The subcommand passed to `git bisect`.
Результат GitWorkingCopy

branch() публичный метод

List, create, or delete branches.
public branch ( ) : GitWorkingCopy
Результат GitWorkingCopy

checkout() публичный метод

Checkout a branch or paths to the working tree.
public checkout ( ) : GitWorkingCopy
Результат GitWorkingCopy

checkoutNewBranch() публичный метод

This is synonymous with git checkout -b.
См. также: GitWorkingCopy::checkout()
public checkoutNewBranch ( string $branch, array $options = [] )
$branch string The new branch being created.
$options array

clean() публичный метод

Remove untracked files from the working tree
public clean ( ) : GitWorkingCopy
Результат GitWorkingCopy

clearOutput() публичный метод

Clears the stored output captured by the last run Git command(s).
public clearOutput ( ) : GitWorkingCopy
Результат GitWorkingCopy

cloneRepository() публичный метод

Clone a repository into a new directory. Use GitWorkingCopy::clone() instead for more readable code.
public cloneRepository ( string $repository, array $options = [] ) : GitWorkingCopy
$repository string The Git URL of the repository being cloned.
$options array (optional) An associative array of command line options.
Результат GitWorkingCopy

commit() публичный метод

Record changes to the repository. If only one argument is passed, it is assumed to be the commit message. Therefore $git->commit('Message'); yields a git commit -am "Message" command.
public commit ( ) : GitWorkingCopy
Результат GitWorkingCopy

config() публичный метод

Get and set repository options.
public config ( ) : GitWorkingCopy
Результат GitWorkingCopy

diff() публичный метод

Show changes between commits, commit and working tree, etc.
public diff ( ) : GitWorkingCopy
Результат GitWorkingCopy

fetch() публичный метод

Download objects and refs from another repository.
public fetch ( ) : GitWorkingCopy
Результат GitWorkingCopy

fetchAll() публичный метод

This is synonymous with git fetch --all.
См. также: GitWorkingCopy::fetch()
public fetchAll ( array $options = [] )
$options array (optional) An associative array of command line options.

getBranches() публичный метод

Returns a GitBranches object containing information on the repository's branches.
public getBranches ( ) : gitwrapper\GitBranches
Результат gitwrapper\GitBranches

getDirectory() публичный метод

Gets the path to the directory containing the working copy.
public getDirectory ( ) : string
Результат string

getOutput() публичный метод

Gets the output captured by the last run Git commnd(s).
public getOutput ( ) : string
Результат string

getRemote() публичный метод

Returns the given remote.
public getRemote ( string $name ) : array
$name string The name of the remote.
Результат array An associative array with the following keys: - fetch: the fetch URL. - push: the push URL.

getRemoteUrl() публичный метод

Returns the fetch or push URL of a given remote.
public getRemoteUrl ( string $remote, string $operation = 'fetch' ) : string
$remote string The name of the remote for which to return the fetch or push URL.
$operation string The operation for which to return the remote. Can be either 'fetch' or 'push'. Defaults to 'fetch'.
Результат string The URL.

getRemotes() публичный метод

Returns all existing remotes.
public getRemotes ( ) : array
Результат array An associative array, keyed by remote name, containing an associative array with the following keys: - fetch: the fetch URL. - push: the push URL.

getStatus() публичный метод

Returns the output of a git status -s command.
public getStatus ( ) : string
Результат string

getWrapper() публичный метод

Returns the GitWrapper object that likely instantiated this class.
public getWrapper ( ) : GitWrapper\GitWrapper
Результат GitWrapper\GitWrapper

grep() публичный метод

Print lines matching a pattern.
public grep ( ) : GitWorkingCopy
Результат GitWorkingCopy

hasChanges() публичный метод

Returns true if there are changes to commit.
public hasChanges ( ) : boolean
Результат boolean

hasRemote() публичный метод

Checks if the given remote exists.
public hasRemote ( string $name ) : boolean
$name string The name of the remote to check.
Результат boolean

init() публичный метод

Create an empty git repository or reinitialize an existing one.
public init ( array $options = [] ) : GitWorkingCopy
$options array (optional) An associative array of command line options.
Результат GitWorkingCopy

isAhead() публичный метод

If this returns true it means that commits are present locally which have not yet been pushed to the remote.
public isAhead ( ) : boolean
Результат boolean

isBehind() публичный метод

If this returns true it means that a pull is needed to bring the branch up-to-date with the remote.
public isBehind ( ) : boolean
Результат boolean

isCloned() публичный метод

If the flag is not set, test if it looks like we're at a git directory.
public isCloned ( ) : boolean
Результат boolean

isTracking() публичный метод

Returns whether HEAD has a remote tracking branch.
public isTracking ( ) : boolean
Результат boolean

isUpToDate() публичный метод

Returns whether HEAD is up-to-date with its remote tracking branch.
public isUpToDate ( ) : boolean
Результат boolean

log() публичный метод

Show commit logs.
public log ( ) : GitWorkingCopy
Результат GitWorkingCopy

merge() публичный метод

Join two or more development histories together.
public merge ( ) : GitWorkingCopy
Результат GitWorkingCopy

mv() публичный метод

Move or rename a file, a directory, or a symlink.
public mv ( string $source, string $destination, array $options = [] ) : GitWorkingCopy
$source string The file / directory being moved.
$destination string The target file / directory that the source is being move to.
$options array (optional) An associative array of command line options.
Результат GitWorkingCopy

needsMerge() публичный метод

If this returns true it means that HEAD has diverged from its remote tracking branch; new commits are present locally as well as on the remote.
public needsMerge ( ) : boolean
Результат boolean true if HEAD needs to be merged with the remote, false otherwise.

pull() публичный метод

Fetch from and merge with another repository or a local branch.
public pull ( ) : GitWorkingCopy
Результат GitWorkingCopy

push() публичный метод

Update remote refs along with associated objects.
public push ( ) : GitWorkingCopy
Результат GitWorkingCopy

pushTag() публичный метод

This is synonymous with git push origin tag v1.2.3.
См. также: GitWorkingCopy::push()
public pushTag ( string $tag, string $repository = 'origin', array $options = [] )
$tag string The tag being pushed.
$repository string The destination of the push operation, which is either a URL or name of the remote. Defaults to "origin".
$options array (optional) An associative array of command line options.

pushTags() публичный метод

This is synonymous with git push --tags origin.
См. также: GitWorkingCopy::push()
public pushTags ( string $repository = 'origin', array $options = [] )
$repository string The destination of the push operation, which is either a URL or name of the remote. Defaults to "origin".
$options array (optional) An associative array of command line options.

rebase() публичный метод

Forward-port local commits to the updated upstream head.
public rebase ( ) : GitWorkingCopy
Результат GitWorkingCopy

remote() публичный метод

Manage the set of repositories ("remotes") whose branches you track.
public remote ( ) : GitWorkingCopy
Результат GitWorkingCopy

removeRemote() публичный метод

Removes the given remote.
public removeRemote ( string $name ) : GitWorkingCopy
$name string The name of the remote to remove.
Результат GitWorkingCopy

reset() публичный метод

Reset current HEAD to the specified state.
public reset ( ) : GitWorkingCopy
Результат GitWorkingCopy

rm() публичный метод

Remove files from the working tree and from the index.
public rm ( string $filepattern, array $options = [] ) : GitWorkingCopy
$filepattern string Files to remove from version control. Fileglobs (e.g. *.c) can be given to add all matching files. Also a leading directory name (e.g. dir to add dir/file1 and dir/file2) can be given to add all files in the directory, recursively.
$options array (optional) An associative array of command line options.
Результат GitWorkingCopy

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

Runs a Git command and captures the output.
См. также: GitWrapper::run()
public run ( array $args, boolean $setDirectory = true ) : GitWorkingCopy
$args array The arguments passed to the command method.
$setDirectory boolean Set the working directory, defaults to true.
Результат GitWorkingCopy

setCloned() публичный метод

Manually sets the cloned flag.
public setCloned ( boolean $cloned ) : GitWorkingCopy
$cloned boolean Whether the repository is cloned into the directory or not.
Результат GitWorkingCopy

show() публичный метод

Show various types of objects.
public show ( string $object, array $options = [] ) : GitWorkingCopy
$object string The names of objects to show. For a more complete list of ways to spell object names, see "SPECIFYING REVISIONS" section in gitrevisions(7).
$options array (optional) An associative array of command line options.
Результат GitWorkingCopy

status() публичный метод

Show the working tree status.
public status ( ) : GitWorkingCopy
Результат GitWorkingCopy

tag() публичный метод

Create, list, delete or verify a tag object signed with GPG.
public tag ( ) : GitWorkingCopy
Результат GitWorkingCopy

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

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

If the variable is null, the a rudimentary check will be performed to see if the directory looks like it is a working copy.
protected $cloned

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

Path to the directory containing the working copy.
protected string $directory
Результат string

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

The output captured by the last run Git commnd(s).
protected string $output
Результат string

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

The GitWrapper object that likely instantiated this class.
protected GitWrapper,GitWrapper $wrapper
Результат GitWrapper\GitWrapper