public function testMergeAbort() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); // branch:master $filesystem->dumpFile($this->directory . '/test.txt', 'foo'); $git->add('test.txt'); $git->commit('master'); // branch:develop $git->checkout->create('develop'); $filesystem->dumpFile($this->directory . '/test.txt', 'bar'); $git->add('test.txt'); $git->commit('develop'); // branch:master $git->checkout('master'); $filesystem->dumpFile($this->directory . '/test.txt', 'baz'); $git->add('test.txt'); $git->commit('master'); try { $git->merge('develop'); $this->fail('$git->merge("develop") should fail'); } catch (Exception $e) { } $git->merge->abort(); $this->assertEquals('baz', file_get_contents($this->directory . '/test.txt')); }
/** * @expectedException \PHPGit\Exception\GitException * @expectedExceptionCode 128 */ public function testException() { $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $git->add('foo'); }
public function testDescribeTags() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/README.md', 'hello'); $git->add('README.md'); $git->commit('Initial commit'); $git->tag->create('v1.0.0'); $version = $git->describe->tags('HEAD'); $this->assertEquals('v1.0.0', $version); $filesystem->dumpFile($this->directory . '/README.md', 'hello2'); $git->add('README.md'); $git->commit('Fixes README'); $version = $git->describe->tags('HEAD'); $this->assertStringStartsWith('v1.0.0', $version); $this->assertStringEndsNotWith('v1.0.0', $version); }
public function setUp() { parent::setUp(); $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/test.txt', ''); $git->add('test.txt'); $git->commit('Initial commit'); }
public function testShow() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/README.md', 'foobar'); $git->add('README.md'); $git->commit('Initial commit'); $git->show('master', array('format' => 'oneline')); }
public function testMv() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/test.txt', 'foo'); $git->add('test.txt'); $git->commit('Initial commit'); $git->mv('test.txt', 'test2.txt'); $this->assertFileExists($this->directory . '/test2.txt'); }
public function testCommit() { $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem = new Filesystem(); $filesystem->dumpFile($this->directory . '/test.txt', ''); $git->add('test.txt'); $git->commit('Initial commit'); $logs = $git->log('test.txt'); $this->assertCount(1, $logs); }
public function testTrackingBranchStatus() { $filesystem = new Filesystem(); $git = new Git(); $git->clone('https://github.com/kzykhys/Text.git', $this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/test.txt', '1'); $git->add('test.txt'); $git->commit('test'); $status = $git->status(); $this->assertEquals('master', $status['branch']); }
public function testCreateTagFromCommit() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/README.md', 'hello'); $git->add('.'); $git->commit('Initial commit'); $log = $git->log(null, null, array('limit' => 1)); $git->tag->create('v1.0.0', $log[0]['hash']); $this->assertCount(1, $git->tag()); }
public function testShortlogSummary() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $git->config->set('user.name', 'Name One'); $git->config->set('user.email', '*****@*****.**'); $filesystem->dumpFile($this->directory . '/test.txt', ''); $git->add('test.txt'); $git->commit('1'); $filesystem->dumpFile($this->directory . '/test2.txt', ''); $git->add('test2.txt'); $git->commit('2'); $git->config->set('user.name', 'Name Two'); $git->config->set('user.email', '*****@*****.**'); $filesystem->dumpFile($this->directory . '/test3.txt', ''); $git->add('test3.txt'); $git->commit('3'); $summary = $git->shortlog->summary(); $this->assertEquals(array('Name One <*****@*****.**>' => 2, 'Name Two <*****@*****.**>' => 1), $summary); }
public function testArchive() { $filesystem = new Filesystem(); $filesystem->mkdir($this->directory); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/test.txt', 'hello'); $git->add('test.txt'); $git->commit('Initial commit'); $git->archive($this->directory . '/test.zip', 'master', null, array('format' => 'zip', 'prefix' => 'test/')); $this->assertFileExists($this->directory . '/test.zip'); }
public function testCatSize() { $filesystem = new Filesystem(); $filesystem->mkdir($this->directory); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/test.txt', 'foo'); $git->add('test.txt'); $git->commit('Initial commit'); $tree = $git->tree(); $this->assertEquals(3, $git->cat->size($tree[0]['hash'])); }
public function testRmCached() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/README.md', 'foo'); $git->add('README.md'); $git->commit('Initial commit'); $git->rm->cached('README.md'); $git->commit('Delete README.md'); $this->assertFileExists($this->directory . '/README.md'); $tree = $git->tree(); $this->assertEquals(array(), $tree); }
public function testPush() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory, array('shared' => true, 'bare' => true)); $git->clone('file://' . realpath($this->directory), $this->directory . '2'); $git->setRepository($this->directory . '2'); $filesystem->dumpFile($this->directory . '2/test.txt', 'foobar'); $git->add('test.txt'); $git->commit('test'); $git->push('origin', 'master'); $git->clone('file://' . realpath($this->directory), $this->directory . '3'); $this->assertFileExists($this->directory . '3/test.txt'); $filesystem->remove($this->directory . '2'); $filesystem->remove($this->directory . '3'); }
public function testRebaseSkip() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/test.txt', 'foo'); $git->add('test.txt'); $git->commit('initial commit'); $git->checkout->create('next'); $filesystem->dumpFile($this->directory . '/test.txt', 'bar'); $git->add('test.txt'); $git->commit('next commit'); $git->checkout('master'); $filesystem->dumpFile($this->directory . '/test.txt', 'baz'); $git->add('test.txt'); $git->commit('master commit'); try { $git->rebase('next'); $this->fail('GitException should be thrown'); } catch (\PHPGit\Exception\GitException $e) { } $git->rebase->skip(); }
/** * @expectedException InvalidArgumentException */ public function testResetInvalidMode() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/README.md', 'foo'); $git->add('README.md'); $git->commit('Initial commit'); $filesystem->dumpFile($this->directory . '/README.md', 'hello'); $git->reset->mode('foo'); }
public function saveWorkingCopy($commitMsg = '') { $this->git->add('.'); return $this->git->commit($commitMsg); }
public function testStashCreate() { $filesystem = new Filesystem(); $git = new Git(); $git->init($this->directory); $git->setRepository($this->directory); $filesystem->dumpFile($this->directory . '/README.md', 'hello'); $git->add('.'); $git->commit('Initial commit'); $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); $object = $git->stash->create(); $this->assertNotEmpty($object); }