/**
* Execute a Git command.
*
* @param string[] $args
* Command arguments (everything after 'git').
* @param string|false $dir
* The path to a Git repository. Set to false if the command should not
* run inside a repository.
* @param bool $mustRun
* Enable exceptions if the Git command fails.
* @param bool $quiet
* Suppress command output.
*
* @throws \RuntimeException If the repository directory is invalid.
*
* @return string|bool
*/
public function execute(array $args, $dir = null, $mustRun = false, $quiet = true)
{
// If enabled, set the working directory to the repository.
if ($dir !== false) {
$dir = $dir ?: $this->repositoryDir;
}
// Run the command.
array_unshift($args, 'git');
return $this->shellHelper->execute($args, $dir, $mustRun, $quiet);
}