當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Git::getWorkingPath方法代碼示例

本文整理匯總了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;
 }
開發者ID:yrizos,項目名稱:berk,代碼行數:54,代碼來源:Berk.php

示例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;
 }
開發者ID:yrizos,項目名稱:berk,代碼行數:14,代碼來源:Git.php


注:本文中的Git::getWorkingPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。