public function deploy()
{
// Create the wrapper.
$wrapper = new GitWrapper();
$wrapper->streamOutput();
// Iterate through each project.
foreach ($this->projects as $name => $project) {
// Check out all branches.
foreach ($project['branches'] as $branch => $destination) {
// Build our git interface.
$git = null;
if (!is_dir($destination)) {
$git = $wrapper->cloneRepository($project['repo'], $destination);
} else {
$git = new GitWorkingCopy($wrapper, $destination);
}
// Fetch the latest.
$git->fetch('origin');
// Checkout the desired branch.
$git->checkout($branch, array('force' => true));
// Reset any local changes.
$git->reset(array('hard' => true));
// Pull the latest from the branch.
$git->pull('origin', $branch, array('force' => true));
}
}
}