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