function hackedProjectWebDevDownloader::git_checkout in Hacked! 8.2
Checks out the last Git commit prior to the project's timestamp.
Parameters
$path: The path of the Git repository where the checkout should happen.
$branch: The desired branch within the repository containing the commit.
$timestamp: The UNIX timestamp for the downloaded project.
Throws
Exception on failure.
1 call to hackedProjectWebDevDownloader::git_checkout()
- hackedProjectWebDevDownloader::download in src/
hackedProjectWebDevDownloader.php - Download the version of the project to compare.
File
- src/
hackedProjectWebDevDownloader.php, line 137
Class
- hackedProjectWebDevDownloader
- Downloads a development snapshot of a project using Git.
Namespace
Drupal\hackedCode
function git_checkout($path, $branch, $timestamp) {
// Fetch the Git command.
$git_cmd = $this
->git_get_command();
// Point the working tree at the commit just before the timestamp.
// This takes us to the point in time when the local project was downloaded.
exec("cd {$path}; {$git_cmd} checkout \$({$git_cmd} rev-list -n 1 --before='{$timestamp}' {$branch})", $output_lines, $return_value);
// Throw an exception if it didn't work.
if ($return_value != 0) {
throw new Exception(t('Could not check out latest commit before %timestamp in Git repository %repository.', [
'%timestamp' => $timestamp,
'%repository' => $path,
]));
}
}