Beispiel #1
0
 public function testShouldHaveObjectType()
 {
     $blob = new GitBlob($this->git);
     $blob->setData('Simulate that a README file was commited and pushed to master.')->store();
     $this->gittag->setObject($blob);
     $this->assertEquals($this->gittag->objType(), GitObject::TYPE_BLOB);
 }
Beispiel #2
0
// Add a commit to develop
$b = new GitBlob($git);
$b->setData("Altered README.md file!!!\n")->store();
echo "Created {$b}\n";
$arr = ['README.md' => $b];
$t = new GitTree($git);
$t->setData($arr)->store();
echo "Created {$t}\n";
$author->setTimestamp('1374058776');
$committer->setTimestamp('1374058776');
$c = new GitCommit($git);
$c->setTree($t->sha())->addParent($oc->sha())->setMessage('Update readme.')->addAuthor($author)->addCommiter($committer)->store();
echo "Created {$c}\n";
$p = $c->sha();
// Add a commit to develop
$b = new GitBlob($git);
$b->setData("Altered README.MD file!\n")->store();
echo "Created {$b}\n";
$arr = ['README.md' => $b];
$t = new GitTree($git);
$t->setData($arr)->store();
echo "Created {$t}\n";
$author->setTimestamp('1374158776');
$committer->setTimestamp('1374158776');
$c = new GitCommit($git);
$c->setTree($t->sha())->addParent($p)->setMessage('Correct readme.')->addAuthor($author)->addCommiter($committer)->store();
echo "Created {$c}\n";
$author->setTimestamp('1384158776');
$committer->setTimestamp('1384158776');
$sc = new GitCommit($git);
$sc->setTree($t->sha())->addParent($firstcommit)->addParent($c->sha())->setMessage('Merge develop into master.')->addAuthor($author)->addCommiter($committer)->store();
Beispiel #3
0
 * Copyright (c) 2015 Martijn van der Kleijn <*****@*****.**>
 * Licensed under the MIT license <http://opensource.org/licenses/MIT>
 */
/* EXAMPLE FROM README */
/*
 * How to use this example:
 *
 * - install php-cli if needed
 * - run it: php <filename>
 * - check the result using instaweb
 *   cd /tmp/mytestrepo
 *   git instaweb
 */
include '../src/git4p.php';
use Git4p\Git;
use Git4p\GitBlob;
use Git4p\GitCommit;
use Git4p\GitTree;
use Git4p\GitUser;
$git = Git::init('/tmp/mytestrepo');
$readme = "GIT4P\n=====\n\nThis is a simple test repo for git4p.\n";
$user = new GitUser();
$user->setName('Some User')->setEmail('*****@*****.**')->setTimestamp('1374058686')->setOffset('+0200');
$b = new GitBlob($git);
$b->setData($readme)->store();
$arr = ['README.md' => $b];
$t = new GitTree($git);
$t->setData($arr)->store();
$c = new GitCommit($git);
$c->setTree($t->sha())->setMessage('Initial commit.')->addAuthor($user)->addCommiter($user)->store();
$git->updateBranch('master', $c->sha());