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


PHP PhabricatorRepository::setVersionControlSystem方法代码示例

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


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

示例1: execute

 protected function execute(ConduitAPIRequest $request)
 {
     if (!$request->getUser()->getIsAdmin()) {
         throw new ConduitException('ERR-PERMISSIONS');
     }
     // TODO: This has some duplication with (and lacks some of the validation
     // of) the web workflow; refactor things so they can share more code as this
     // stabilizes.
     $repository = new PhabricatorRepository();
     $repository->setName($request->getValue('name'));
     $callsign = $request->getValue('callsign');
     if (!preg_match('/[A-Z]+$/', $callsign)) {
         throw new ConduitException('ERR-BAD-CALLSIGN');
     }
     $repository->setCallsign($callsign);
     $vcs = $request->getValue('vcs');
     $map = array('git' => PhabricatorRepositoryType::REPOSITORY_TYPE_GIT, 'hg' => PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL, 'svn' => PhabricatorRepositoryType::REPOSITORY_TYPE_SVN);
     if (empty($map[$vcs])) {
         throw new ConduitException('ERR-UNKNOWN-REPOSITORY-VCS');
     }
     $repository->setVersionControlSystem($map[$vcs]);
     $details = array('encoding' => $request->getValue('encoding'), 'description' => $request->getValue('description'), 'tracking-enabled' => (bool) $request->getValue('tracking', true), 'remote-uri' => $request->getValue('uri'), 'local-path' => $request->getValue('localPath'), 'branch-filter' => array_fill_keys($request->getValue('branchFilter', array()), true), 'close-commits-filter' => array_fill_keys($request->getValue('closeCommitsFilter', array()), true), 'pull-frequency' => $request->getValue('pullFrequency'), 'default-branch' => $request->getValue('defaultBranch'), 'ssh-login' => $request->getValue('sshUser'), 'ssh-key' => $request->getValue('sshKey'), 'ssh-keyfile' => $request->getValue('sshKeyFile'), 'herald-disabled' => !$request->getValue('heraldEnabled', true), 'svn-subpath' => $request->getValue('svnSubpath'), 'disable-autoclose' => !$request->getValue('autocloseEnabled', true));
     foreach ($details as $key => $value) {
         $repository->setDetail($key, $value);
     }
     try {
         $repository->save();
     } catch (AphrontQueryDuplicateKeyException $ex) {
         throw new ConduitException('ERR-DUPLICATE');
     }
     return $this->buildDictForRepository($repository);
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:32,代码来源:ConduitAPI_repository_create_Method.php

示例2: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $e_name = true;
     $e_callsign = true;
     $repository = new PhabricatorRepository();
     $type_map = PhabricatorRepositoryType::getAllRepositoryTypes();
     $errors = array();
     if ($request->isFormPost()) {
         $repository->setName($request->getStr('name'));
         $repository->setCallsign($request->getStr('callsign'));
         $repository->setVersionControlSystem($request->getStr('type'));
         if (!strlen($repository->getName())) {
             $e_name = 'Required';
             $errors[] = 'Repository name is required.';
         } else {
             $e_name = null;
         }
         if (!strlen($repository->getCallsign())) {
             $e_callsign = 'Required';
             $errors[] = 'Callsign is required.';
         } else {
             if (!preg_match('/^[A-Z]+$/', $repository->getCallsign())) {
                 $e_callsign = 'Invalid';
                 $errors[] = 'Callsign must be ALL UPPERCASE LETTERS.';
             } else {
                 $e_callsign = null;
             }
         }
         if (empty($type_map[$repository->getVersionControlSystem()])) {
             $errors[] = 'Invalid version control system.';
         }
         if (!$errors) {
             try {
                 $repository->save();
                 return id(new AphrontRedirectResponse())->setURI('/repository/edit/' . $repository->getID() . '/');
             } catch (AphrontQueryDuplicateKeyException $ex) {
                 $e_callsign = 'Duplicate';
                 $errors[] = 'Callsign must be unique. Another repository already ' . 'uses that callsign.';
             }
         }
     }
     $error_view = null;
     if ($errors) {
         $error_view = new AphrontErrorView();
         $error_view->setErrors($errors);
         $error_view->setTitle('Form Errors');
     }
     $form = new AphrontFormView();
     $form->setUser($user)->setAction('/repository/create/')->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($repository->getName())->setError($e_name)->setCaption('Human-readable repository name.'))->appendChild('<p class="aphront-form-instructions">Select a "Callsign" &mdash; a ' . 'short, uppercase string to identify revisions in this repository. If ' . 'you choose "EX", revisions in this repository will be identified ' . 'with the prefix "rEX".</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('Callsign')->setName('callsign')->setValue($repository->getCallsign())->setError($e_callsign)->setCaption('Short, UPPERCASE identifier. Once set, it can not be changed.'))->appendChild(id(new AphrontFormSelectControl())->setLabel('Type')->setName('type')->setOptions($type_map)->setValue($repository->getVersionControlSystem()))->appendChild(id(new AphrontFormSubmitControl())->setValue('Create Repository')->addCancelButton('/repository/'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Create Repository');
     $panel->appendChild($form);
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Create Repository'));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:57,代码来源:PhabricatorRepositoryCreateController.php

示例3: testBranchFilter

 public function testBranchFilter()
 {
     $git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
     $repo = new PhabricatorRepository();
     $repo->setVersionControlSystem($git);
     $this->assertEqual(true, $repo->shouldTrackBranch('imaginary'), 'Track all branches by default.');
     $repo->setDetail('branch-filter', array('master' => true));
     $this->assertEqual(true, $repo->shouldTrackBranch('master'), 'Track listed branches.');
     $this->assertEqual(false, $repo->shouldTrackBranch('imaginary'), 'Do not track unlisted branches.');
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:10,代码来源:PhabricatorRepositoryTestCase.php

示例4: testSubversionPathInfo

 public function testSubversionPathInfo()
 {
     $svn = PhabricatorRepositoryType::REPOSITORY_TYPE_SVN;
     $repo = new PhabricatorRepository();
     $repo->setVersionControlSystem($svn);
     $repo->setDetail('remote-uri', 'http://svn.example.com/repo');
     $this->assertEqual('http://svn.example.com/repo', $repo->getSubversionPathURI());
     $repo->setDetail('remote-uri', 'http://svn.example.com/repo/');
     $this->assertEqual('http://svn.example.com/repo', $repo->getSubversionPathURI());
     $repo->setDetail('hosting-enabled', true);
     $repo->setLocalPath('/var/repo/SVN');
     $this->assertEqual('file:///var/repo/SVN', $repo->getSubversionPathURI());
     $repo->setLocalPath('/var/repo/SVN/');
     $this->assertEqual('file:///var/repo/SVN', $repo->getSubversionPathURI());
     $this->assertEqual('file:///var/repo/SVN/a@', $repo->getSubversionPathURI('a'));
     $this->assertEqual('file:///var/repo/SVN/a@1', $repo->getSubversionPathURI('a', 1));
     $this->assertEqual('file:///var/repo/SVN/%3F@22', $repo->getSubversionPathURI('?', 22));
     $repo->setDetail('svn-subpath', 'quack/trunk/');
     $this->assertEqual('file:///var/repo/SVN/quack/trunk/@', $repo->getSubversionBaseURI());
     $this->assertEqual('file:///var/repo/SVN/quack/trunk/@HEAD', $repo->getSubversionBaseURI('HEAD'));
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:21,代码来源:PhabricatorRepositoryTestCase.php


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