当前位置: 首页>>代码示例>>PHP>>正文


PHP Git类代码示例

本文整理汇总了PHP中Git的典型用法代码示例。如果您正苦于以下问题:PHP Git类的具体用法?PHP Git怎么用?PHP Git使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Git类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Execute the command.
  *
  * @param Input $input
  * @param Output $output
  * @return void
  */
 protected function execute(Input $input, Output $output)
 {
     $name = $input->getArgument("name");
     // Validate the name straight away.
     if (count($chunks = explode("/", $name)) != 2) {
         throw new \InvalidArgumentException("Invalid repository name '{$name}'.");
     }
     $output->writeln(sprintf("Cloning <comment>%s</comment> into <info>%s/%s</info>...", $name, getcwd(), end($chunks)));
     // If we're in a test environment, stop executing.
     if (defined("ADVISER_UNDER_TEST")) {
         return null;
     }
     // @codeCoverageIgnoreStart
     if (!$this->git->cloneGithubRepository($name)) {
         throw new \UnexpectedValueException("Repository https://github.com/{$name} doesn't exist.");
     }
     // Change the working directory.
     chdir($path = getcwd() . "/" . end($chunks));
     $output->writeln(sprintf("Changed the current working directory to <comment>%s</comment>.", $path));
     $output->writeln("");
     // Running "AnalyseCommand"...
     $arrayInput = [""];
     if (!is_null($input->getOption("formatter"))) {
         $arrayInput["--formatter"] = $input->getOption("formatter");
     }
     $this->getApplication()->find("analyse")->run(new ArrayInput($arrayInput), $output);
     // Change back, remove the directory.
     chdir(getcwd() . "/..");
     $this->removeDirectory($path);
     $output->writeln("");
     $output->writeln(sprintf("Switching back to <info>%s</info>, removing <comment>%s</comment>...", getcwd(), $path));
     // @codeCoverageIgnoreStop
 }
开发者ID:bound1ess,项目名称:adviser,代码行数:40,代码来源:AnalyseRepositoryCommand.php

示例2: scanFile

 /**
  * git ls-folder HEAD
  * @return Array            $path => $blob
  */
 public function scanFile()
 {
     $this->git->createGitProcess(['ls-tree', '--full-name', 'HEAD']);
     while ($this->git->isRunning()) {
         # code...
     }
     $output = $this->getOutput();
     return 9;
 }
开发者ID:nothing628,项目名称:git-control,代码行数:13,代码来源:GitObject.php

示例3: getGit

 /**
  * @return Git
  */
 public function getGit()
 {
     if (is_null($this->git)) {
         $this->git = new Git();
         /** @var Logger $logger */
         $logger = $this->getMockBuilder('Logger')->disableOriginalConstructor()->getMock();
         $this->git->setLogger($logger);
     }
     return $this->git;
 }
开发者ID:monsieurchico,项目名称:php-twgit,代码行数:13,代码来源:GitTest.php

示例4: display

 public function display()
 {
     $git_php_viewer = new GitViews_GitPhpViewer($this->repository, $this->controller->getPlugin()->getConfigurationParameter('gitphp_path'));
     if ($this->request->get('noheader') == 1) {
         $view = new GitViews_ShowRepo_Download($git_php_viewer);
     } else {
         $view = new GitViews_ShowRepo_Content($this->repository, $git_php_viewer, $this->request->getCurrentUser(), $this->controller, $this->url_manager, $this->driver_factory, $this->gerrit_usermanager, $this->mirror_data_mapper, $this->gerrit_servers, $this->controller->getPlugin()->getThemePath());
     }
     $view->display();
 }
开发者ID:uniteddiversity,项目名称:tuleap,代码行数:10,代码来源:ShowRepo.class.php

示例5: deleteFile

 public function deleteFile($formData)
 {
     $result = false;
     if (is_array($formData) && isset($formData['name'])) {
         $git = new Git();
         $result = $git->rmFile($this->getPath() . $formData['name']);
     } else {
         throw new Exception('New file form data in incorrect format');
     }
     return $result;
 }
开发者ID:reveil,项目名称:CodeTornado,代码行数:11,代码来源:FileNavigation.php

示例6: deleteAction

 public function deleteAction()
 {
     $response = new \Phalcon\Http\Response();
     $delete_url = $this->request->getPost("delete_url");
     $status = Git::deleteRepository($delete_url, $this->session->get('token'));
     return $response->setContent($status);
 }
开发者ID:sq3hll,项目名称:github_Api,代码行数:7,代码来源:MainController.php

示例7: git_read_tag

function git_read_tag($proj, $tag_id)
{
    $obj = $proj->getObject($tag_id);
    if ($obj->getType() != Git::OBJ_TAG) {
        return;
    }
    $tag['id'] = sha1_hex($tag_id);
    if ($obj->object !== null) {
        $tag['object'] = sha1_hex($obj->object);
    }
    if ($obj->objtype !== null) {
        $tag['type'] = Git::getTypeName($obj->objtype);
    }
    if ($obj->tag !== null) {
        $tag['name'] = $obj->tag;
    }
    if ($obj->tagger !== null) {
        $tag['author'] = $obj->tagger->name;
        $tag['epoch'] = $obj->tagger->time;
        $tag['tz'] = sprintf("%+03d%02d", $obj->tagger->offset / 3600, abs($obj->tagger->offset % 3600 / 60));
    }
    $tag['comment'] = explode("\n", $obj->summary . "\n" . $obj->detail);
    if (!isset($tag['name'])) {
        return null;
    }
    return $tag;
}
开发者ID:akumpf,项目名称:gitphp-glip,代码行数:27,代码来源:glip.git_read_tag.php

示例8: beforeSave

 function beforeSave()
 {
     if (!$this['type']) {
         throw $this->exception('Please specify type', 'ValidityCheck')->setField('type');
     }
     $existing_check = $this->add('Model_MarketPlace');
     $existing_check->addCondition('id', '<>', $this->id);
     $existing_check->addCondition('namespace', $this['namespace']);
     $existing_check->tryLoadAny();
     if ($existing_check->loaded()) {
         throw $this->exception('Name Space Already Used', 'ValidityCheck')->setField('namespace');
     }
     // TODO :: check namespace on server as well...
     if (file_exists(getcwd() . DS . 'epan-components' . DS . $this['namespace']) and !$this->isInstalling) {
         throw $this->exception('namespace folder is already created', 'ValidityCheck')->setField('namespace');
     }
     if (!$this->isInstalling) {
         //Added in AddComponentTorepository View
         $create_component_folder = true;
         if ($this['initialize_and_clone_from_git'] and $this['git_path']) {
             $repo = Git::create($dest = getcwd() . DS . 'epan-components' . DS . $this['namespace'], $this['git_path']);
             $create_component_folder = false;
         }
         $this->createNewFiles($create_component_folder);
     }
 }
开发者ID:xepan,项目名称:xepan,代码行数:26,代码来源:MarketPlace.php

示例9: checklog

/**
 * Check Log
 *
 * This function finds that last tag for the current release and shows you 
 * any changes between them
 *
 * @param The git module directory
 * @return String of `git log` output
 */
function checklog($moddir)
{
    $repo = Git::open($moddir);
    $ltags = $repo->list_tags();
    if ($ltags === false) {
        return 'No Tags found!';
    }
    list($rawname, $ver, $supported) = freepbx::check_xml_file($moddir);
    //Get current module version
    preg_match('/(\\d*\\.\\d*)\\./i', $ver, $matches);
    $rver = $matches[1];
    //cycle through the tags and create a new array with relavant tags
    $tagArray = array();
    foreach ($ltags as $tag) {
        if (preg_match('/release\\/(.*)/i', $tag, $matches)) {
            if (strpos($matches[1], $rver) !== false) {
                $tagArray[] = $matches[1];
            }
        }
    }
    if (!empty($tagArray)) {
        usort($tagArray, "freepbx::version_compare_freepbx");
        $htag = array_pop($tagArray);
        $tagref = $repo->show_ref_tag($htag);
        return $repo->log($tagref, 'HEAD');
    }
    return;
}
开发者ID:FreePBX,项目名称:devtools,代码行数:37,代码来源:checklog.php

示例10: joinProject

 /**
  * Associate user with the project. Owner is automatically assigned by newProject calling this method.
  * This method also creates the git repository and assigns basic configuration
  */
 public function joinProject($pid)
 {
     if ($this->_uid == false) {
         throw new Exception(NO_USER);
     }
     $data = array('pid' => $pid, 'uid' => $this->_uid);
     $result = $this->_db->insert('user_project', $data);
     //returns the number of rows inserted
     if ($result == 1) {
         //select the project as the active project once the required db entry exists
         $this->selectProject($pid);
         $git = new Git();
         if ($this->active->owner == $this->_uid) {
             if (file_exists($this->getPath() . $this->_userPath)) {
                 throw new Exception('User directory in project folder already exists');
             }
             if (!mkdir($this->getPath() . $this->_userPath)) {
                 throw new Exception('Unable to create a user directory in the project folder');
             }
             //===== GIT INIT =====
             $git->initRepo($this->_userName, $this->_userEmail);
         } else {
             //clone should crete the user directory as it is required to clone to new dir
             //===== GIT CLONE =====
             $git->cloneRepo($this->_userName, $this->_userEmail, $this->active->owner, $this->_uid);
         }
     }
 }
开发者ID:reveil,项目名称:CodeTornado,代码行数:32,代码来源:Project.php

示例11: initRepo

 private function initRepo()
 {
     //get path to the repo root (by default DokuWiki's savedir)
     if (defined('DOKU_FARM')) {
         $repoPath = $this->getConf('repoPath');
     } else {
         $repoPath = DOKU_INC . $this->getConf('repoPath');
     }
     //set the path to the git binary
     $gitPath = trim($this->getConf('gitPath'));
     if ($gitPath !== '') {
         Git::set_bin($gitPath);
     }
     //init the repo and create a new one if it is not present
     io_mkdir_p($repoPath);
     $repo = new GitRepo($repoPath, true, true);
     //set git working directory (by default DokuWiki's savedir)
     $repoWorkDir = DOKU_INC . $this->getConf('repoWorkDir');
     Git::set_bin(Git::get_bin() . ' --work-tree ' . escapeshellarg($repoWorkDir));
     $params = str_replace(array('%mail%', '%user%'), array($this->getAuthorMail(), $this->getAuthor()), $this->getConf('addParams'));
     if ($params) {
         Git::set_bin(Git::get_bin() . ' ' . $params);
     }
     return $repo;
 }
开发者ID:MarcinKlejna,项目名称:dokuwiki-plugin-gitbacked,代码行数:25,代码来源:editcommit.php

示例12: inspect

 public static function inspect()
 {
     $repo = Git::open(ABSPATH);
     if (is_object($repo) && $repo->test_git()) {
         $status_data = $repo->run('status --porcelain');
         $changed_files = array();
         if (preg_match_all('/(^.+?)\\s(.*)$/m', $status_data, $changes, PREG_SET_ORDER)) {
             foreach ($changes as $changed_item) {
                 $change = trim($changed_item[1]);
                 $file = trim($changed_item[2]);
                 $changed_files[$change][] = $file;
             }
         }
         $routine_options = ACI_Routine_Handler::get_options(__CLASS__);
         if (!is_array($routine_options)) {
             $routine_options = array();
         }
         if (!is_array($routine_options['changed_files'])) {
             $routine_options['changed_files'] = array();
         }
         if (empty($routine_options['ignore_files'])) {
             $routine_options['ignore_files'] = self::$_default_ignore_files;
         } else {
             if (!is_array($routine_options['ignore_files'])) {
                 $routine_options['ignore_files'] = (array) $routine_options['ignore_files'];
             }
         }
         foreach (array_keys($changed_files) as $change) {
             foreach ($routine_options['ignore_files'] as $file_path) {
                 if (!empty($file_path)) {
                     $files_to_ignore = preg_grep('/^' . str_replace('\\*', '*', preg_quote($file_path, '/') . '/'), $changed_files[$change]);
                     if (is_array($files_to_ignore) && count($files_to_ignore) > 0) {
                         foreach (array_keys($files_to_ignore) as $ignore_file_key) {
                             unset($changed_files[$change][$ignore_file_key]);
                         }
                     }
                 }
             }
             if (count($changed_files[$change]) > 0) {
                 switch ($change) {
                     case 'A':
                         AC_Inspector::log('Git repository has ' . count($changed_files[$change]) . ' NEW file(s).', __CLASS__);
                         break;
                     case 'M':
                         AC_Inspector::log('Git repository has ' . count($changed_files[$change]) . ' MODIFIED file(s).', __CLASS__);
                         break;
                     case 'D':
                         AC_Inspector::log('Git repository has ' . count($changed_files[$change]) . ' DELETED file(s).', __CLASS__);
                         break;
                     case '??':
                         AC_Inspector::log('Git repository has ' . count($changed_files[$change]) . ' UNTRACKED file(s).', __CLASS__);
                         break;
                 }
             }
         }
         $routine_options['changed_files'] = $changed_files;
         ACI_Routine_Handler::set_options(__CLASS__, $routine_options);
     }
 }
开发者ID:Angrycreative,项目名称:Angry-Creative-Inspector,代码行数:59,代码来源:git_status.php

示例13: setDirectory

 /**
  * @param $directory
  *
  * @throws \InvalidArgumentException
  *
  * @return $this
  */
 public function setDirectory($directory)
 {
     if (!Git::isGitRepository($directory)) {
         throw new \InvalidArgumentException("Directory doesn't appear to be a git repository");
     }
     $this->directory = realpath($directory);
     return $this;
 }
开发者ID:yrizos,项目名称:git,代码行数:15,代码来源:Git.php

示例14: git

/**
 * Return the single instance of the Git class
 *
 */
function git()
{
    if (!class_exists("Git")) {
        oik_require("includes/class-git.php", "oik-batch");
    }
    $git = Git::instance();
    return $git;
}
开发者ID:bobbingwide,项目名称:oik-libs,代码行数:12,代码来源:oik-git.php

示例15: data

 public function data()
 {
     $data = '';
     uasort($this->entries(), 'self::compare');
     foreach ($this->entries() as $name => $entry) {
         $data .= sprintf("%s %s%s", $entry->mode(), $name, Git::sha2bin($entry->sha()));
     }
     return $data;
 }
开发者ID:git4p,项目名称:git4p,代码行数:9,代码来源:GitTree.php


注:本文中的Git类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。