Beispiel #1
0
 public function testDiff()
 {
     $mainCommand = new MainCommand();
     $diffCommand = new DiffCommand();
     $this->getRepository()->init();
     $this->addFile('foo', null, "content line 1\ncontent line 2\ncontent line 3");
     $this->getRepository()->commit('commit1', true);
     $this->addFile('foo', null, "content line 1\ncontent line 2 changed");
     $this->getRepository()->commit('commit2', true);
     $commit = $this->getRepository()->getCommit();
     $diff = Diff::create($this->getRepository(), $commit);
     $this->assertInstanceOf('\\GitElephant\\Objects\\Diff\\Diff', $diff);
     $this->assertArrayInterfaces($diff);
     $this->assertCount(1, $diff);
     $object = $diff[0];
     $this->assertInstanceOf('\\GitElephant\\Objects\\Diff\\DiffObject', $object);
     $this->assertArrayInterfaces($object);
     $this->assertCount(1, $object);
     $chunk = $object[0];
     $this->assertInstanceOf('\\GitElephant\\Objects\\Diff\\DiffChunk', $chunk);
     $this->assertArrayInterfaces($chunk);
     $this->assertCount(5, $chunk);
     foreach ($chunk as $chunkLine) {
         $this->assertInstanceOf('\\GitElephant\\Objects\\Diff\\DiffChunkLine', $chunkLine);
     }
 }
Beispiel #2
0
 /**
  * Get a Diff object for a commit with its parent, by default the diff is between the current head and its parent
  *
  * @param \GitElephant\Objects\Commit|string      $commit1 A TreeishInterface instance
  * @param \GitElephant\Objects\Commit|string|null $commit2 A TreeishInterface instance
  * @param null|string|Object                      $path    The path to get the diff for or a Object instance
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @return Objects\Diff\Diff
  */
 public function getDiff($commit1 = null, $commit2 = null, $path = null)
 {
     return Diff::create($this, $commit1, $commit2, $path);
 }