コード例 #1
0
ファイル: MergeCommandTest.php プロジェクト: szoper/PHPGit
 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'));
 }
コード例 #2
0
ファイル: RmCommandTest.php プロジェクト: szoper/PHPGit
 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);
 }
コード例 #3
0
ファイル: DescribeCommandTest.php プロジェクト: szoper/PHPGit
 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);
 }
コード例 #4
0
 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');
 }
コード例 #5
0
ファイル: ShowCommandTest.php プロジェクト: dnaber-de/PHPGit
 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'));
 }
コード例 #6
0
ファイル: MvCommandTest.php プロジェクト: dnaber-de/PHPGit
 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');
 }
コード例 #7
0
 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);
 }
コード例 #8
0
 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']);
 }
コード例 #9
0
ファイル: ShortlogCommandTest.php プロジェクト: szoper/PHPGit
 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);
 }
コード例 #10
0
ファイル: TagCommandTest.php プロジェクト: dnaber-de/PHPGit
 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());
 }
コード例 #11
0
ファイル: ArchiveCommandTest.php プロジェクト: szoper/PHPGit
 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');
 }
コード例 #12
0
ファイル: CatCommandTest.php プロジェクト: dnaber-de/PHPGit
 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']));
 }
コード例 #13
0
ファイル: PushCommandTest.php プロジェクト: szoper/PHPGit
 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');
 }
コード例 #14
0
ファイル: ResetCommandTest.php プロジェクト: szoper/PHPGit
 /**
  * @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');
 }
コード例 #15
0
ファイル: Git.php プロジェクト: bonndan/release-flow
 public function saveWorkingCopy($commitMsg = '')
 {
     $this->git->add('.');
     return $this->git->commit($commitMsg);
 }
コード例 #16
0
ファイル: StashCommandTest.php プロジェクト: szoper/PHPGit
 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);
 }
コード例 #17
0
ファイル: RebaseCommandTest.php プロジェクト: szoper/PHPGit
 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();
 }