PHP Class GitWrapper\GitWorkingCopy

All commands executed via an instance of this class act on the working copy that is set through the constructor.
Afficher le fichier Open project: cpliakas/git-wrapper Class Usage Examples

Protected Properties

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
__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.

Method Details

__call() public méthode

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

__construct() public méthode

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() public méthode

Gets the output captured by the last run Git commnd(s).
See also: GitWorkingCopy::getOutput()
public __toString ( ) : string
Résultat string

add() public méthode

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.
Résultat GitWorkingCopy

addRemote() public méthode

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.
Résultat GitWorkingCopy

apply() public méthode

Apply a patch to files and/or to the index
public apply ( ) : GitWorkingCopy
Résultat GitWorkingCopy

archive() public méthode

Create an archive of files from a named tree
public archive ( ) : GitWorkingCopy
Résultat GitWorkingCopy

bisect() public méthode

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`.
Résultat GitWorkingCopy

branch() public méthode

List, create, or delete branches.
public branch ( ) : GitWorkingCopy
Résultat GitWorkingCopy

checkout() public méthode

Checkout a branch or paths to the working tree.
public checkout ( ) : GitWorkingCopy
Résultat GitWorkingCopy

checkoutNewBranch() public méthode

This is synonymous with git checkout -b.
See also: GitWorkingCopy::checkout()
public checkoutNewBranch ( string $branch, array $options = [] )
$branch string The new branch being created.
$options array

clean() public méthode

Remove untracked files from the working tree
public clean ( ) : GitWorkingCopy
Résultat GitWorkingCopy

clearOutput() public méthode

Clears the stored output captured by the last run Git command(s).
public clearOutput ( ) : GitWorkingCopy
Résultat GitWorkingCopy

cloneRepository() public méthode

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.
Résultat GitWorkingCopy

commit() public méthode

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
Résultat GitWorkingCopy

config() public méthode

Get and set repository options.
public config ( ) : GitWorkingCopy
Résultat GitWorkingCopy

diff() public méthode

Show changes between commits, commit and working tree, etc.
public diff ( ) : GitWorkingCopy
Résultat GitWorkingCopy

fetch() public méthode

Download objects and refs from another repository.
public fetch ( ) : GitWorkingCopy
Résultat GitWorkingCopy

fetchAll() public méthode

This is synonymous with git fetch --all.
See also: GitWorkingCopy::fetch()
public fetchAll ( array $options = [] )
$options array (optional) An associative array of command line options.

getBranches() public méthode

Returns a GitBranches object containing information on the repository's branches.
public getBranches ( ) : gitwrapper\GitBranches
Résultat gitwrapper\GitBranches

getDirectory() public méthode

Gets the path to the directory containing the working copy.
public getDirectory ( ) : string
Résultat string

getOutput() public méthode

Gets the output captured by the last run Git commnd(s).
public getOutput ( ) : string
Résultat string

getRemote() public méthode

Returns the given remote.
public getRemote ( string $name ) : array
$name string The name of the remote.
Résultat array An associative array with the following keys: - fetch: the fetch URL. - push: the push URL.

getRemoteUrl() public méthode

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'.
Résultat string The URL.

getRemotes() public méthode

Returns all existing remotes.
public getRemotes ( ) : array
Résultat 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() public méthode

Returns the output of a git status -s command.
public getStatus ( ) : string
Résultat string

getWrapper() public méthode

Returns the GitWrapper object that likely instantiated this class.
public getWrapper ( ) : GitWrapper\GitWrapper
Résultat GitWrapper\GitWrapper

grep() public méthode

Print lines matching a pattern.
public grep ( ) : GitWorkingCopy
Résultat GitWorkingCopy

hasChanges() public méthode

Returns true if there are changes to commit.
public hasChanges ( ) : boolean
Résultat boolean

hasRemote() public méthode

Checks if the given remote exists.
public hasRemote ( string $name ) : boolean
$name string The name of the remote to check.
Résultat boolean

init() public méthode

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.
Résultat GitWorkingCopy

isAhead() public méthode

If this returns true it means that commits are present locally which have not yet been pushed to the remote.
public isAhead ( ) : boolean
Résultat boolean

isBehind() public méthode

If this returns true it means that a pull is needed to bring the branch up-to-date with the remote.
public isBehind ( ) : boolean
Résultat boolean

isCloned() public méthode

If the flag is not set, test if it looks like we're at a git directory.
public isCloned ( ) : boolean
Résultat boolean

isTracking() public méthode

Returns whether HEAD has a remote tracking branch.
public isTracking ( ) : boolean
Résultat boolean

isUpToDate() public méthode

Returns whether HEAD is up-to-date with its remote tracking branch.
public isUpToDate ( ) : boolean
Résultat boolean

log() public méthode

Show commit logs.
public log ( ) : GitWorkingCopy
Résultat GitWorkingCopy

merge() public méthode

Join two or more development histories together.
public merge ( ) : GitWorkingCopy
Résultat GitWorkingCopy

mv() public méthode

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.
Résultat GitWorkingCopy

needsMerge() public méthode

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
Résultat boolean true if HEAD needs to be merged with the remote, false otherwise.

pull() public méthode

Fetch from and merge with another repository or a local branch.
public pull ( ) : GitWorkingCopy
Résultat GitWorkingCopy

push() public méthode

Update remote refs along with associated objects.
public push ( ) : GitWorkingCopy
Résultat GitWorkingCopy

pushTag() public méthode

This is synonymous with git push origin tag v1.2.3.
See also: 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() public méthode

This is synonymous with git push --tags origin.
See also: 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() public méthode

Forward-port local commits to the updated upstream head.
public rebase ( ) : GitWorkingCopy
Résultat GitWorkingCopy

remote() public méthode

Manage the set of repositories ("remotes") whose branches you track.
public remote ( ) : GitWorkingCopy
Résultat GitWorkingCopy

removeRemote() public méthode

Removes the given remote.
public removeRemote ( string $name ) : GitWorkingCopy
$name string The name of the remote to remove.
Résultat GitWorkingCopy

reset() public méthode

Reset current HEAD to the specified state.
public reset ( ) : GitWorkingCopy
Résultat GitWorkingCopy

rm() public méthode

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.
Résultat GitWorkingCopy

run() public méthode

Runs a Git command and captures the output.
See also: 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.
Résultat GitWorkingCopy

setCloned() public méthode

Manually sets the cloned flag.
public setCloned ( boolean $cloned ) : GitWorkingCopy
$cloned boolean Whether the repository is cloned into the directory or not.
Résultat GitWorkingCopy

show() public méthode

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.
Résultat GitWorkingCopy

status() public méthode

Show the working tree status.
public status ( ) : GitWorkingCopy
Résultat GitWorkingCopy

tag() public méthode

Create, list, delete or verify a tag object signed with GPG.
public tag ( ) : GitWorkingCopy
Résultat GitWorkingCopy

Property Details

$cloned protected_oe property

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 protected_oe property

Path to the directory containing the working copy.
protected string $directory
Résultat string

$output protected_oe property

The output captured by the last run Git commnd(s).
protected string $output
Résultat string

$wrapper protected_oe property

The GitWrapper object that likely instantiated this class.
protected GitWrapper,GitWrapper $wrapper
Résultat GitWrapper\GitWrapper