本文整理汇总了PHP中Git::getWorkingPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Git::getWorkingPath方法的具体用法?PHP Git::getWorkingPath怎么用?PHP Git::getWorkingPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Git
的用法示例。
在下文中一共展示了Git::getWorkingPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseConfiguration
public static function parseConfiguration($path)
{
if (!is_file($path) || !is_readable($path)) {
throw new \InvalidArgumentException('Path ' . $path . ' is invalid.');
}
$config = @json_decode(file_get_contents($path), true);
if (!is_array($config)) {
throw new \Exception('Configuration file is invalid.');
}
if (!isset($config['name']) || empty($config['name'])) {
$name = Git::getWorkingDirectory();
$name = explode(DIRECTORY_SEPARATOR, $name);
$name = array_pop($name);
$config['name'] = $name;
}
if (!isset($config['servers']) || !is_array($config['servers'])) {
$config['servers'] = [];
}
foreach ($config['servers'] as $k => $server) {
if (!isset($server['host']) || !isset($server['username']) || !isset($server['password'])) {
throw new \Exception('Configuration for server ' . $k . ' is invalid.');
}
if (!isset($server['port'])) {
$server['port'] = 21;
}
if (!isset($server['path'])) {
$server['path'] = '/';
}
$config['servers'][$k] = $server;
}
$config['ignore'] = isset($config['ignore']) && is_array($config['ignore']) ? $config['ignore'] : [];
$config['ignore'][] = $path;
$config['ignore'][] = self::EXPORT_DIRECTORY;
$config['ignore'][] = '.git';
$config['ignore'][] = '.idea';
$config['ignore'][] = '.gitignore';
$config['ignore'][] = '.gitattributes';
$config['ignore'][] = '.travis.yml';
$config['ignore'][] = 'LICENSE';
$config['ignore'][] = 'README.md';
foreach ($config['ignore'] as $key => $path) {
if (!file_exists($path)) {
$path = Git::getWorkingPath($path);
}
$path = realpath($path);
if ($path) {
$config['ignore'][$key] = $path;
} else {
unset($config['ignore'][$key]);
}
}
$config['ignore'] = array_unique($config['ignore']);
return $config;
}
示例2: getUncommittedFiles
public static function getUncommittedFiles()
{
$output = self::exec('status --porcelain');
if (empty($output)) {
$output = [];
}
$output = array_map(function ($path) {
$path = trim($path);
$path = explode(' ', $path);
$path = array_pop($path);
return Git::getWorkingPath($path);
}, $output);
return $output;
}