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


PHP PhabricatorRepository::getRemoteURI方法代码示例

本文整理汇总了PHP中PhabricatorRepository::getRemoteURI方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorRepository::getRemoteURI方法的具体用法?PHP PhabricatorRepository::getRemoteURI怎么用?PHP PhabricatorRepository::getRemoteURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorRepository的用法示例。


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

示例1: verifyGitOrigin

 /**
  * Verify that the "origin" remote exists, and points at the correct URI.
  *
  * This catches or corrects some types of misconfiguration, and also repairs
  * an issue where Git 1.7.1 does not create an "origin" for `--bare` clones.
  * See T4041.
  *
  * @param   PhabricatorRepository Repository to verify.
  * @return  void
  */
 protected function verifyGitOrigin(PhabricatorRepository $repository)
 {
     try {
         list($remotes) = $repository->execxLocalCommand('remote show -n origin');
     } catch (CommandException $ex) {
         throw new PhutilProxyException(pht('Expected to find a Git working copy at path "%s", but the ' . 'path exists and is not a valid working copy. If you remove ' . 'this directory, the daemons will automatically recreate it ' . 'correctly. Phabricator will not destroy the directory for you ' . 'because it can not be sure that it does not contain important ' . 'data.', $repository->getLocalPath()), $ex);
     }
     $matches = null;
     if (!preg_match('/^\\s*Fetch URL:\\s*(.*?)\\s*$/m', $remotes, $matches)) {
         throw new Exception(pht("Expected '%s' in '%s'.", 'Fetch URL', 'git remote show -n origin'));
     }
     $remote_uri = $matches[1];
     $expect_remote = $repository->getRemoteURI();
     if ($remote_uri == 'origin') {
         // If a remote does not exist, git pretends it does and prints out a
         // made up remote where the URI is the same as the remote name. This is
         // definitely not correct.
         // Possibly, we should use `git remote --verbose` instead, which does not
         // suffer from this problem (but is a little more complicated to parse).
         $valid = false;
         $exists = false;
     } else {
         $normal_type_git = PhabricatorRepositoryURINormalizer::TYPE_GIT;
         $remote_normal = id(new PhabricatorRepositoryURINormalizer($normal_type_git, $remote_uri))->getNormalizedPath();
         $expect_normal = id(new PhabricatorRepositoryURINormalizer($normal_type_git, $expect_remote))->getNormalizedPath();
         $valid = $remote_normal == $expect_normal;
         $exists = true;
     }
     if (!$valid) {
         if (!$exists) {
             // If there's no "origin" remote, just create it regardless of how
             // strongly we own the working copy. There is almost no conceivable
             // scenario in which this could do damage.
             $this->log(pht('Remote "origin" does not exist. Creating "origin", with ' . 'URI "%s".', $expect_remote));
             $repository->execxLocalCommand('remote add origin %P', $repository->getRemoteURIEnvelope());
             // NOTE: This doesn't fetch the origin (it just creates it), so we won't
             // know about origin branches until the next "pull" happens. That's fine
             // for our purposes, but might impact things in the future.
         } else {
             if ($repository->canDestroyWorkingCopy()) {
                 // Bad remote, but we can try to repair it.
                 $this->log(pht('Remote "origin" exists, but is pointed at the wrong URI, "%s". ' . 'Resetting origin URI to "%s.', $remote_uri, $expect_remote));
                 $repository->execxLocalCommand('remote set-url origin %P', $repository->getRemoteURIEnvelope());
             } else {
                 // Bad remote and we aren't comfortable repairing it.
                 $message = pht('Working copy at "%s" has a mismatched origin URI, "%s". ' . 'The expected origin URI is "%s". Fix your configuration, or ' . 'set the remote URI correctly. To avoid breaking anything, ' . 'Phabricator will not automatically fix this.', $repository->getLocalPath(), $remote_uri, $expect_remote);
                 throw new Exception($message);
             }
         }
     }
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:61,代码来源:PhabricatorRepositoryEngine.php

示例2: getCleanGitWorkspace

 /**
  * Creates and/or cleans a workspace for the requested repo.
  *
  * return ArcanistGitAPI
  */
 public static function getCleanGitWorkspace(PhabricatorRepository $repo)
 {
     $origin_path = $repo->getLocalPath();
     $path = rtrim($origin_path, '/');
     $path = $path . '__workspace';
     if (!Filesystem::pathExists($path)) {
         $repo->execxLocalCommand('clone -- file://%s %s', $origin_path, $path);
         if (!$repo->isHosted()) {
             id(new ArcanistGitAPI($path))->execxLocal('remote set-url origin %s', $repo->getRemoteURI());
         }
     }
     $workspace = new ArcanistGitAPI($path);
     $workspace->execxLocal('clean -f -d');
     $workspace->execxLocal('checkout master');
     $workspace->execxLocal('fetch');
     $workspace->execxLocal('reset --hard origin/master');
     $workspace->reloadWorkingCopy();
     return $workspace;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:24,代码来源:DifferentialGetWorkingCopy.php

示例3: executeCreate

 protected function executeCreate(PhabricatorRepository $repository, $local_path)
 {
     $repository->execxRemoteCommand('clone --origin origin %s %s', $repository->getRemoteURI(), rtrim($local_path, '/'));
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:4,代码来源:PhabricatorRepositoryGitFetchDaemon.php

示例4: executeHgCreate

 /**
  * @task hg
  */
 private function executeHgCreate(PhabricatorRepository $repository, $path)
 {
     $repository->execxRemoteCommand('clone %s %s', $repository->getRemoteURI(), rtrim($path, '/'));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:7,代码来源:PhabricatorRepositoryPullLocalDaemon.php


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