[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/differential/ -> DifferentialGetWorkingCopy.php (source)

   1  <?php
   2  
   3  /**
   4   * Can't find a good place for this, so I'm putting it in the most notably
   5   * wrong place.
   6   */
   7  final class DifferentialGetWorkingCopy {
   8  
   9    /**
  10     * Creates and/or cleans a workspace for the requested repo.
  11     *
  12     * return ArcanistGitAPI
  13     */
  14    public static function getCleanGitWorkspace(
  15      PhabricatorRepository $repo) {
  16  
  17      $origin_path = $repo->getLocalPath();
  18  
  19      $path = rtrim($origin_path, '/');
  20      $path = $path.'__workspace';
  21  
  22      if (!Filesystem::pathExists($path)) {
  23        $repo->execxLocalCommand(
  24          'clone -- file://%s %s',
  25          $origin_path,
  26          $path);
  27  
  28        if (!$repo->isHosted()) {
  29          id(new ArcanistGitAPI($path))->execxLocal(
  30            'remote set-url origin %s',
  31            $repo->getRemoteURI());
  32        }
  33      }
  34  
  35      $workspace = new ArcanistGitAPI($path);
  36      $workspace->execxLocal('clean -f -d');
  37      $workspace->execxLocal('checkout master');
  38      $workspace->execxLocal('fetch');
  39      $workspace->execxLocal('reset --hard origin/master');
  40      $workspace->reloadWorkingCopy();
  41  
  42      return $workspace;
  43    }
  44  
  45    /**
  46     * Creates and/or cleans a workspace for the requested repo.
  47     *
  48     * return ArcanistMercurialAPI
  49     */
  50    public static function getCleanMercurialWorkspace(
  51      PhabricatorRepository $repo) {
  52  
  53      $origin_path = $repo->getLocalPath();
  54  
  55      $path = rtrim($origin_path, '/');
  56      $path = $path.'__workspace';
  57  
  58      if (!Filesystem::pathExists($path)) {
  59        $repo->execxLocalCommand(
  60          'clone -- file://%s %s',
  61          $origin_path,
  62          $path);
  63      }
  64  
  65      $workspace = new ArcanistMercurialAPI($path);
  66      $workspace->execxLocal('pull');
  67      $workspace->execxLocal('update --clean default');
  68      $workspace->reloadWorkingCopy();
  69  
  70      return $workspace;
  71    }
  72  
  73  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1