2017 © Pedro Peláez
 

library git-wrapper

A wrapper for the git command line executable, based on YiiGit (https://github.com/phpnode/YiiGit). Allows access to all git commands via a simple object oriented interface.

image

carrlabs/git-wrapper

A wrapper for the git command line executable, based on YiiGit (https://github.com/phpnode/YiiGit). Allows access to all git commands via a simple object oriented interface.

  • Thursday, October 3, 2013
  • by BrentGoldthwaite
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,010 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Introduction

A wrapper for the git command line executable, based on YiiGit. Allows access to all git commands via a simple object oriented interface., (*1)

Usage examples

Add some files and folders to git, (*2)

$repository = new \CarrLabs\GitWrapper\GitRepository('path/to/your/git/repo');
$repository->add('somefile.txt');
$repository->add('somedirectory');

Commit some files with git, (*3)

$repository->commit('Added some files');

Checkout an existing branch, (*4)

$repository->checkout('some-existing-branch');
echo $repository->getActiveBranch()->name; // some-existing-branch

Checkout a new branch, (*5)

$repository->checkout('some-new-branch', TRUE);
echo $repository->getActiveBranch()->name; // some-new-branch

List all branches, (*6)

foreach($repository->getBranches() as $branch)
{
    echo $branch->name . "\n";
}

List all tags with metadata, (*7)

foreach($repository->getTags() as $tag)
{
    echo $tag->name . "\n";
    echo $tag->getAuthorName() . "\n";
    echo $tag->getAuthorEmail() . "\n";
    echo $tag->getMessage() . "\n";
}

List all the commits on the current branch, (*8)

foreach($repository->getActiveBranch()->getCommits() as $commit)
{
    echo $commit->getAuthorName() . ' at ' . $commit->getTime() . "\n";
    echo $commit->getMessage() . "\n";
    echo str_repeat('-', 50) . "\n";
}

List all the files affected by the latest commit, (*9)

foreach($repository->getActiveBranch()->getLastCommit()->getFiles() as $file)
{
    echo $file . "\n";
}

Check if a tag exists on the default remote ('origin'), (*10)

$repository->getRemote()->hasTag('myTag');

List all branches on a remote repository called 'upstream', (*11)

foreach($repository->getRemote('upstream')->getBranches() as $branch)
{
    echo $branch . "\n";
}

API

\CarrLabs\GitWrapper\GitRepository, (*12)

setPath($path, $createIfEmpty = false, $initialize = false)
getPath()
run($command)
add($file)
rm($file, $force = false)
commit($message = null, $addFiles = false, $amend = false)
status()
describe($options = '')
checkout($branchName, $create = false, $force = false)
clean($deleteDirectories = false, $force = false)
cloneTo($targetDirectory)
cloneFrom($targetDirectory)
cloneRemote($sourceUrl)
push($remote, $branch = "master", $force = false)
fetch($repository)
getActiveBranch()
getBranches()
hasBranch($branch)
createBranch($branchName)
deleteBranch($branchName, $force = false)
getCommit($hash)
getTags()
getTag($name)
hasTag($tag)
addTag($name, $message, $hash = null)
removeTag($tag)
getRemotes()
getRemote($remote = null)
hasCommit($hash)

\CarrLabs\GitWrapper\GitCommit, (*13)

getAuthorName()
getAuthorEmail()
getTime()
getSubject()
getMessage()
getNotes()
getParents()
getFiles()

\CarrLabs\GitWrapper\GitBranch, (*14)

getCommits()
getCommit($hash)
getLastCommit()

\CarrLabs\GitWrapper\GitTag, (*15)

push($remote = null)
getAuthorName()
getAuthorEmail()
getMessage()
getCommit()

\CarrLabs\GitWrapper\GitRemote, (*16)

getBranches()
hasBranch($branch)
deleteBranch($branchName)
getTags()
hasTag($tag)

The Versions

03/10 2013

dev-master

9999999-dev https://github.com/CarrLabs/git-wrapper

A wrapper for the git command line executable, based on YiiGit (https://github.com/phpnode/YiiGit). Allows access to all git commands via a simple object oriented interface.

  Sources   Download

BSD-2-Clause

by Brent Goldthwaite

git vcs