1
0
Fork 0

Fixing perforce dev-master stored reference bug.

pull/2834/head
Clark Stuth 2014-03-21 13:42:00 -05:00
parent 8fc1961463
commit 2651cbc5fe
2 changed files with 31 additions and 10 deletions

View File

@ -315,11 +315,7 @@ class Perforce
chdir($this->path); chdir($this->path);
$p4SyncCommand = $this->generateP4Command('sync -f '); $p4SyncCommand = $this->generateP4Command('sync -f ');
if (isset($label)) {
if (strcmp($label, 'dev-master') != 0) {
$p4SyncCommand = $p4SyncCommand . '@' . $label; $p4SyncCommand = $p4SyncCommand . '@' . $label;
}
}
$this->executeCommand($p4SyncCommand); $this->executeCommand($p4SyncCommand);
chdir($prevDir); chdir($prevDir);
@ -481,9 +477,15 @@ class Perforce
} }
} }
} }
$branches = array(); $command = $this->generateP4Command('changes '. $this->getStream() . '/...', false);
$branches['master'] = $possibleBranches[$this->p4Branch]; $this->executeCommand($command);
$result = $this->commandResult;
$resArray = explode(PHP_EOL, $result);
$lastCommit = $resArray[0];
$lastCommitArr = explode(' ', $lastCommit);
$lastCommitNum = $lastCommitArr[1];
$branches = array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
return $branches; return $branches;
} }
@ -501,7 +503,6 @@ class Perforce
$tags[$fields[1]] = $this->getStream() . '@' . $fields[1]; $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
} }
} }
return $tags; return $tags;
} }

View File

@ -351,15 +351,35 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
} }
) )
); );
$expectedCommand2 = 'p4 -u user -p port changes //depot/branch/...';
$expectedCallback = function($command, &$output)
{
$output = 'Change 1234 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\'';
return true;
};
$this->processExecutor->expects($this->at(1))
->method('execute')
->with($this->equalTo($expectedCommand2))
->will($this->returnCallback($expectedCallback));
$branches = $this->perforce->getBranches(); $branches = $this->perforce->getBranches();
$this->assertEquals('//depot/branch', $branches['master']); $this->assertEquals('//depot/branch@1234', $branches['master']);
} }
public function testGetBranchesWithoutStream() public function testGetBranchesWithoutStream()
{ {
$expectedCommand = 'p4 -u user -p port changes //depot/...';
$expectedCallback = function($command, &$output)
{
$output = 'Change 5678 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\'';
return true;
};
$this->processExecutor->expects($this->once())
->method('execute')
->with($this->equalTo($expectedCommand))
->will($this->returnCallback($expectedCallback));
$branches = $this->perforce->getBranches(); $branches = $this->perforce->getBranches();
$this->assertEquals('//depot', $branches['master']); $this->assertEquals('//depot@5678', $branches['master']);
} }
public function testGetTagsWithoutStream() public function testGetTagsWithoutStream()