Beispiel #1
0
 public function testExpandHash()
 {
     $strategymock = $this->getMock('GitPHP_ProjectLoadStrategy_Interface');
     $strategymock->expects($this->once())->method('ExpandHash')->with($this->isInstanceOf('GitPHP_Project'), $this->equalTo('shorthash'))->will($this->returnValue('longhash'));
     $project = new GitPHP_Project(GITPHP_TEST_PROJECTROOT, 'testrepo.git', $strategymock);
     $this->assertEquals('longhash', $project->ExpandHash('shorthash'));
 }
 /**
  * Gets a file diff
  *
  * @param string $fromHash source hash, can also be a diff-tree info line
  * @param string $toHash target hash, required if $fromHash is a hash
  * @return GitPHP_FileDiff file diff object
  */
 public function GetFileDiff($fromHash, $toHash = '')
 {
     if (preg_match('/^[0-9A-Fa-f]{4,39}$/', $fromHash) && !$this->compat) {
         $fullHash = $this->project->ExpandHash($fromHash);
         if ($fullHash == $fromHash) {
             throw new GitPHP_InvalidHashException($fromHash);
         }
         $fromHash = $fullHash;
     }
     if (!empty($toHash) && preg_match('/^[0-9A-Fa-f]{4,39}$/', $toHash) && !$this->compat) {
         $fullHash = $this->project->ExpandHash($toHash);
         if ($fullHash == $toHash) {
             throw new GitPHP_InvalidHashException($toHash);
         }
         $toHash = $fullHash;
     }
     $fileDiff = new GitPHP_FileDiff($this->project, $fromHash, $toHash);
     $fileDiff->SetCache($this->cache);
     return $fileDiff;
 }