Esempio n. 1
0
 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $ok = $err == 0;
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match('/^(.*?):(\\d+):((\\d+):)? (\\S+): ((\\s|\\w)+): (.*)$/', $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         if ($matches[4] != '') {
             $message->setChar($matches[4]);
         }
         $message->setCode($this->getLinterName());
         $message->setName($matches[6]);
         $message->setDescription($matches[8]);
         $message->setSeverity($this->getLintMessageSeverity($matches[5]));
         $messages[] = $message;
     }
     return $messages;
 }
Esempio n. 2
0
 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match('/^(.*?):(\\d+): (.*)$/', $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $severity = ArcanistLintSeverity::SEVERITY_WARNING;
         $description = $matches[3];
         $error_regexp = '/(^undefined|^duplicate|before assignment$)/';
         if (preg_match($error_regexp, $description)) {
             $severity = ArcanistLintSeverity::SEVERITY_ERROR;
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         $message->setCode($this->getLinterName());
         $message->setDescription($description);
         $message->setSeverity($severity);
         $messages[] = $message;
     }
     return $messages;
 }
Esempio n. 3
0
 private function unfoldICSLines($data)
 {
     $lines = phutil_split_lines($data, $retain_endings = false);
     $this->lines = $lines;
     // ICS files are wrapped at 75 characters, with overlong lines continued
     // on the following line with an initial space or tab. Unwrap all of the
     // lines in the file.
     // This unwrapping is specifically byte-oriented, not character oriented,
     // and RFC5545 anticipates that simple implementations may even split UTF8
     // characters in the middle.
     $last = null;
     foreach ($lines as $idx => $line) {
         $this->cursor = $idx;
         if (!preg_match('/^[ \\t]/', $line)) {
             $last = $idx;
             continue;
         }
         if ($last === null) {
             $this->raiseParseFailure(self::PARSE_INITIAL_UNFOLD, pht('First line of ICS file begins with a space or tab, but this ' . 'marks a line which should be unfolded.'));
         }
         $lines[$last] = $lines[$last] . substr($line, 1);
         unset($lines[$idx]);
     }
     return $lines;
 }
 protected function renderResultList(array $pastes, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($pastes, 'PhabricatorPaste');
     $viewer = $this->requireViewer();
     $lang_map = PhabricatorEnv::getEnvConfig('pygments.dropdown-choices');
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($pastes as $paste) {
         $created = phabricator_date($paste->getDateCreated(), $viewer);
         $author = $handles[$paste->getAuthorPHID()]->renderLink();
         $snippet_type = $paste->getSnippet()->getType();
         $lines = phutil_split_lines($paste->getSnippet()->getContent());
         $preview = id(new PhabricatorSourceCodeView())->setLines($lines)->setTruncatedFirstBytes($snippet_type == PhabricatorPasteSnippet::FIRST_BYTES)->setTruncatedFirstLines($snippet_type == PhabricatorPasteSnippet::FIRST_LINES)->setURI(new PhutilURI($paste->getURI()));
         $source_code = phutil_tag('div', array('class' => 'phabricator-source-code-summary'), $preview);
         $created = phabricator_datetime($paste->getDateCreated(), $viewer);
         $line_count = count($lines);
         $line_count = pht('%s Line(s)', new PhutilNumber($line_count));
         $title = nonempty($paste->getTitle(), pht('(An Untitled Masterwork)'));
         $item = id(new PHUIObjectItemView())->setObjectName('P' . $paste->getID())->setHeader($title)->setHref('/P' . $paste->getID())->setObject($paste)->addByline(pht('Author: %s', $author))->addIcon('none', $created)->addIcon('none', $line_count)->appendChild($source_code);
         if ($paste->isArchived()) {
             $item->setDisabled(true);
         }
         $lang_name = $paste->getLanguage();
         if ($lang_name) {
             $lang_name = idx($lang_map, $lang_name, $lang_name);
             $item->addIcon('none', $lang_name);
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No pastes found.'));
     return $result;
 }
 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     // Each line looks like this:
     // Line 46, E:0110: Line too long (87 characters).
     $regex = '/^Line (\\d+), (E:\\d+): (.*)/';
     $severity_code = ArcanistLintSeverity::SEVERITY_ERROR;
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $line = trim($line);
         $matches = null;
         if (!preg_match($regex, $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[1]);
         $message->setName($matches[2]);
         $message->setCode($this->getLinterName());
         $message->setDescription($matches[3]);
         $message->setSeverity($severity_code);
         $messages[] = $message;
     }
     return $messages;
 }
 public static function summarizeCommitMessage($message)
 {
     $summary = phutil_split_lines($message, $retain_endings = false);
     $summary = head($summary);
     $summary = id(new PhutilUTF8StringTruncator())->setMaximumBytes(self::SUMMARY_MAX_LENGTH)->truncateString($summary);
     return $summary;
 }
 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         // stdin:2: W802 undefined name 'foo'  # pyflakes
         // stdin:3:1: E302 expected 2 blank lines, found 1  # pep8
         $regexp = '/^(.*?):(\\d+):(?:(\\d+):)? (\\S+) (.*)$/';
         if (!preg_match($regexp, $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         if (!empty($matches[3])) {
             $message->setChar($matches[3]);
         }
         $message->setCode($matches[4]);
         $message->setName($this->getLinterName() . ' ' . $matches[3]);
         $message->setDescription($matches[5]);
         $message->setSeverity($this->getLintMessageSeverity($matches[4]));
         $messages[] = $message;
     }
     return $messages;
 }
 public function getTextList()
 {
     if (!$this->textList) {
         return phutil_split_lines($this->getCorpus(), $retain_ends = false);
     }
     return $this->textList;
 }
 public function markupText($text, $children)
 {
     $text = trim($text);
     $lines = phutil_split_lines($text);
     if (count($lines) > 1) {
         $level = $lines[1][0] == '=' ? 1 : 2;
         $text = trim($lines[0]);
     } else {
         $level = 0;
         for ($ii = 0; $ii < min(5, strlen($text)); $ii++) {
             if ($text[$ii] == '=' || $text[$ii] == '#') {
                 ++$level;
             } else {
                 break;
             }
         }
         $text = trim($text, ' =#');
     }
     $engine = $this->getEngine();
     if ($engine->isTextMode()) {
         $char = $level == 1 ? '=' : '-';
         return $text . "\n" . str_repeat($char, phutil_utf8_strlen($text));
     }
     $use_anchors = $engine->getConfig('header.generate-toc');
     $anchor = null;
     if ($use_anchors) {
         $anchor = $this->generateAnchor($level, $text);
     }
     $text = phutil_tag('h' . ($level + 1), array('class' => 'remarkup-header'), array($anchor, $this->applyRules($text)));
     return $text;
 }
 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = explode('|', $line, 5);
         if (count($matches) < 5) {
             continue;
         }
         $message = id(new ArcanistLintMessage())->setPath($path)->setLine($matches[0])->setChar($matches[1])->setCode($this->getLinterName())->setName(ucwords(str_replace('_', ' ', $matches[3])))->setDescription(ucfirst($matches[4]));
         switch ($matches[2]) {
             case 'warning':
                 $message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
                 break;
             case 'error':
                 $message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
                 break;
             default:
                 $message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
                 break;
         }
         $messages[] = $message;
     }
     return $messages;
 }
 public function markupText($text, $children)
 {
     $text = $this->applyRules($text);
     if ($this->getEngine()->isTextMode()) {
         $children = phutil_split_lines($children, true);
         foreach ($children as $key => $child) {
             if (strlen(trim($child))) {
                 $children[$key] = '> ' . $child;
             } else {
                 $children[$key] = '>' . $child;
             }
         }
         $children = implode('', $children);
         return $text . "\n\n" . $children;
     }
     if ($this->getEngine()->isHTMLMailMode()) {
         $block_attributes = array('style' => 'border-left: 3px solid #8C98B8;
       color: #6B748C;
       font-style: italic;
       margin: 4px 0 12px 0;
       padding: 8px 12px;
       background-color: #F8F9FC;');
         $head_attributes = array('style' => 'font-style: normal;
       padding-bottom: 4px;');
         $reply_attributes = array('style' => 'margin: 0;
       padding: 0;
       border: 0;
       color: rgb(107, 116, 140);');
     } else {
         $block_attributes = array('class' => 'remarkup-reply-block');
         $head_attributes = array('class' => 'remarkup-reply-head');
         $reply_attributes = array('class' => 'remarkup-reply-body');
     }
     return phutil_tag('blockquote', $block_attributes, array("\n", phutil_tag('div', $head_attributes, $text), "\n", phutil_tag('div', $reply_attributes, $children), "\n"));
 }
Esempio n. 12
0
 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stderr, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = explode(':', $line, 6);
         if (count($matches) === 6) {
             $message = new ArcanistLintMessage();
             $message->setPath($path);
             $message->setLine($matches[3]);
             $message->setChar($matches[4]);
             $code = "E00";
             $message->setCode($code);
             $message->setName($this->getLinterName());
             $message->setDescription(ucfirst(trim($matches[5])));
             $severity = $this->getLintMessageSeverity($code);
             $message->setSeverity($severity);
             $messages[] = $message;
         }
         if (count($matches) === 3) {
             $message = new ArcanistLintMessage();
             $message->setPath($path);
             $message->setLine($matches[1]);
             $code = "E01";
             $message->setCode($code);
             $message->setName($this->getLinterName());
             $message->setDescription(ucfirst(trim($matches[2])));
             $severity = $this->getLintMessageSeverity($code);
             $message->setSeverity($severity);
             $messages[] = $message;
         }
     }
     return $messages;
 }
Esempio n. 13
0
 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stderr, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match('/(.*?):(\\d+): (.*?)$/', $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $code = head(explode(',', $matches[3]));
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         $message->setCode($this->getLinterName());
         $message->setName(pht('Syntax Error'));
         $message->setDescription($matches[3]);
         $message->setSeverity($this->getLintMessageSeverity($code));
         $messages[] = $message;
     }
     if ($err && !$messages) {
         return false;
     }
     return $messages;
 }
 public function run()
 {
     $root = $this->getWorkingCopy()->getProjectRoot() . '/extension/';
     $start_time = microtime(true);
     id(new ExecFuture('phpize && ./configure && make -j4'))->setCWD($root)->resolvex();
     $out = id(new ExecFuture('make -f Makefile.local test_with_exit_status'))->setCWD($root)->setEnv(array('TEST_PHP_ARGS' => '-q'))->resolvex();
     // NOTE: REPORT_EXIT_STATUS doesn't seem to work properly in some versions
     // of PHP. Just "parse" stdout to approximate the results.
     list($stdout) = $out;
     $tests = array();
     foreach (phutil_split_lines($stdout) as $line) {
         $matches = null;
         // NOTE: The test script writes the name of the test originally, then
         // uses "\r" to erase it and write the result. This splits as a single
         // line.
         if (preg_match('/^TEST .*\\r(PASS|FAIL) (.*)/', $line, $matches)) {
             if ($matches[1] == 'PASS') {
                 $result = ArcanistUnitTestResult::RESULT_PASS;
             } else {
                 $result = ArcanistUnitTestResult::RESULT_FAIL;
             }
             $name = trim($matches[2]);
             $tests[] = id(new ArcanistUnitTestResult())->setName($name)->setResult($result)->setDuration(microtime(true) - $start_time);
         }
     }
     return $tests;
 }
 private function stripQuotedText($body)
 {
     // Look for "On <date>, <user> wrote:". This may be split across multiple
     // lines. We need to be careful not to remove all of a message like this:
     //
     //   On which day do you want to meet?
     //
     //   On <date>, <user> wrote:
     //   > Let's set up a meeting.
     $start = null;
     $lines = phutil_split_lines($body);
     foreach ($lines as $key => $line) {
         if (preg_match('/^\\s*>?\\s*On\\b/', $line)) {
             $start = $key;
         }
         if ($start !== null) {
             if (preg_match('/\\bwrote:/', $line)) {
                 $lines = array_slice($lines, 0, $start);
                 $body = implode('', $lines);
                 break;
             }
         }
     }
     // Outlook english
     $body = preg_replace('/^\\s*(> )?-----Original Message-----.*?/imsU', '', $body);
     // Outlook danish
     $body = preg_replace('/^\\s*(> )?-----Oprindelig Meddelelse-----.*?/imsU', '', $body);
     // See example in T3217.
     $body = preg_replace('/^________________________________________\\s+From:.*?/imsU', '', $body);
     return rtrim($body);
 }
 public static function summarizeCommitMessage($message)
 {
     $max_bytes = id(new PhabricatorRepositoryCommit())->getColumnMaximumByteLength('summary');
     $summary = phutil_split_lines($message, $retain_endings = false);
     $summary = head($summary);
     $summary = id(new PhutilUTF8StringTruncator())->setMaximumBytes($max_bytes)->setMaximumGlyphs(80)->truncateString($summary);
     return $summary;
 }
 private static function strPadLines($text, $num_spaces = 2)
 {
     $text_lines = phutil_split_lines($text);
     foreach ($text_lines as $linenr => $line) {
         $text_lines[$linenr] = str_repeat(" ", $num_spaces) . $line;
     }
     return implode("", $text_lines);
 }
 public function markupText($text, $children)
 {
     if ($this->getEngine()->isTextMode()) {
         $lines = phutil_split_lines($children);
         return '> ' . implode("\n> ", $lines);
     }
     return phutil_tag('blockquote', array(), $children);
 }
 public function markupText($text, $children)
 {
     $text = preg_replace('/%%%\\s*$/', '', substr($text, 3));
     if ($this->getEngine()->isTextMode()) {
         return $text;
     }
     $text = phutil_split_lines($text, $retain_endings = true);
     return phutil_implode_html(phutil_tag('br', array()), $text);
 }
 public function receiveMessage(PhabricatorBotMessage $message)
 {
     switch ($message->getCommand()) {
         case 'MESSAGE':
             $matches = null;
             $text = $message->getBody();
             $target_name = $message->getTarget()->getName();
             if (empty($this->recentlyMentioned[$target_name])) {
                 $this->recentlyMentioned[$target_name] = array();
             }
             $pattern = '@^' . '(?:' . $this->getConfig('nick', 'phabot') . ')?' . '.?\\s*tell me about ' . '(.*)' . '$@';
             if (preg_match($pattern, $text, $matches)) {
                 $slug = $matches[1];
                 $quiet_until = idx($this->recentlyMentioned[$target_name], $slug, 0) + 60 * 10;
                 if (time() < $quiet_until) {
                     // Remain quiet on this channel.
                     break;
                 } else {
                     $this->recentlyMentioned[$target_name][$slug] = time();
                 }
                 try {
                     $result = $this->getConduit()->callMethodSynchronous('phriction.info', array('slug' => 'docbot/docs/' . $slug));
                 } catch (ConduitClientException $ex) {
                     phlog($ex);
                     $result = null;
                 }
                 $response = array();
                 if ($result) {
                     $content = phutil_split_lines($result['content'], $retain_newlines = false);
                     foreach ($content as $line) {
                         $response = array_merge($response, str_split($line, 400));
                         if (count($response) >= 3) {
                             break;
                         }
                     }
                 } else {
                     $response[] = "Nothing to say about " . $slug;
                 }
                 foreach (array_slice($response, 0, 3) as $output) {
                     $this->replyTo($message, html_entity_decode($output));
                 }
                 break;
             }
             $pattern = '@' . $this->getConfig('nick', 'phabot') . ' remember ' . '(.*?)' . ' as:' . '(.*)$' . '@';
             if (preg_match($pattern, $text, $matches)) {
                 $result = $this->getConduit()->callMethodSynchronous('phriction.edit', array('slug' => 'docbot/docs/' . $matches[1], 'content' => $matches[2]));
                 $slug = explode('/', trim($result['slug'], '/'), 3);
                 $output = "Saved as '{$slug[2]}' at {$result['uri']}";
                 $this->replyTo($message, $output);
                 unset($this->recentlyMentioned[$target_name][$slug[2]]);
                 unset($this->recentlyMentioned[$target_name][$matches[1]]);
                 break;
             }
             break;
     }
 }
 public function lintPath($path)
 {
     $lines = phutil_split_lines($this->getData($path), false);
     foreach ($lines as $lineno => $line) {
         // An unresolved merge conflict will contain a series of seven
         // '<', '=', or '>'.
         if (preg_match('/^(>{7}|<{7}|={7})$/', $line)) {
             $this->raiseLintAtLine($lineno + 1, 1, self::LINT_MERGECONFLICT, pht('This syntax indicates there is an unresolved merge conflict.'));
         }
     }
 }
 protected function getLandingCommits()
 {
     $api = $this->getRepositoryAPI();
     list($out) = $api->execxLocal('log --oneline %s..%s --', $this->getTargetFullRef(), $this->sourceCommit);
     $out = trim($out);
     if (!strlen($out)) {
         return array();
     } else {
         return phutil_split_lines($out, false);
     }
 }
Esempio n. 23
0
 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stdout, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match('/^Line (\\d+), E:(\\d+): (.*)/', $line, $matches)) {
             continue;
         }
         $message = id(new ArcanistLintMessage())->setPath($path)->setLine($matches[1])->setName('GJSLINT' . $matches[2])->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR)->setCode($this->getLinterName() . $matches[2])->setDescription($matches[3]);
         $messages[] = $message;
     }
     return $messages;
 }
 protected function resolveBlameFuture(ExecFuture $future)
 {
     list($err, $stdout) = $future->resolve();
     if ($err) {
         return null;
     }
     $result = array();
     $lines = phutil_split_lines($stdout);
     foreach ($lines as $line) {
         list($commit) = explode(' ', $line, 2);
         $result[] = $commit;
     }
     return $result;
 }
 public function markupText($text, $children)
 {
     $text = rtrim($text);
     $text = phutil_split_lines($text, $retain_endings = true);
     foreach ($text as $key => $line) {
         $line = preg_replace('/^\\s*%%%/', '', $line);
         $line = preg_replace('/%%%(\\s*)\\z/', '\\1', $line);
         $text[$key] = $line;
     }
     if ($this->getEngine()->isTextMode()) {
         return implode('', $text);
     }
     return phutil_tag('p', array('class' => 'remarkup-literal'), phutil_implode_html(phutil_tag('br', array()), $text));
 }
Esempio n. 26
0
 public function update()
 {
     $this->updateMemory();
     if (!$this->isRunning()) {
         if (!$this->shouldRestart) {
             return;
         }
         if (!$this->restartAt || time() < $this->restartAt) {
             return;
         }
         if ($this->shouldShutdown) {
             return;
         }
         $this->startDaemonProcess();
     }
     $future = $this->future;
     $result = null;
     if ($future->isReady()) {
         $result = $future->resolve();
     }
     list($stdout, $stderr) = $future->read();
     $future->discardBuffers();
     if (strlen($stdout)) {
         $this->didReadStdout($stdout);
     }
     $stderr = trim($stderr);
     if (strlen($stderr)) {
         foreach (phutil_split_lines($stderr, false) as $line) {
             $this->logMessage('STDE', $line);
         }
     }
     if ($result !== null) {
         list($err) = $result;
         if ($err) {
             $this->logMessage('FAIL', pht('Process exited with error %s.', $err));
         } else {
             $this->logMessage('DONE', pht('Process exited normally.'));
         }
         $this->future = null;
         if ($this->shouldShutdown) {
             $this->restartAt = null;
         } else {
             $this->scheduleRestart();
         }
     }
     $this->updateHeartbeatEvent();
     $this->updateHangDetection();
 }
Esempio n. 27
0
 public function render()
 {
     if (!$this->paste) {
         throw new PhutilInvalidStateException('setPaste');
     }
     $lines = phutil_split_lines($this->paste->getContent());
     require_celerity_resource('paste-css');
     $link = phutil_tag('a', array('href' => '/P' . $this->paste->getID()), $this->handle->getFullName());
     $head = phutil_tag('div', array('class' => 'paste-embed-head'), $link);
     $body_attributes = array('class' => 'paste-embed-body');
     if ($this->lines != null) {
         $body_attributes['style'] = 'max-height: ' . $this->lines * 1.15 . 'em;';
     }
     $body = phutil_tag('div', $body_attributes, id(new PhabricatorSourceCodeView())->setLines($lines)->setHighlights($this->highlights)->disableHighlightOnClick());
     return phutil_tag('div', array('class' => 'paste-embed'), array($head, $body));
 }
 public function getAdapter()
 {
     if (!$this->adapter) {
         $conf = $this->getProviderConfig();
         $realname_attributes = $conf->getProperty(self::KEY_REALNAME_ATTRIBUTES);
         if (!is_array($realname_attributes)) {
             $realname_attributes = array();
         }
         $search_attributes = $conf->getProperty(self::KEY_SEARCH_ATTRIBUTES);
         $search_attributes = phutil_split_lines($search_attributes, false);
         $search_attributes = array_filter($search_attributes);
         $adapter = id(new PhutilLDAPAuthAdapter())->setHostname($conf->getProperty(self::KEY_HOSTNAME))->setPort($conf->getProperty(self::KEY_PORT))->setBaseDistinguishedName($conf->getProperty(self::KEY_DISTINGUISHED_NAME))->setSearchAttributes($search_attributes)->setUsernameAttribute($conf->getProperty(self::KEY_USERNAME_ATTRIBUTE))->setRealNameAttributes($realname_attributes)->setLDAPVersion($conf->getProperty(self::KEY_VERSION))->setLDAPReferrals($conf->getProperty(self::KEY_REFERRALS))->setLDAPStartTLS($conf->getProperty(self::KEY_START_TLS))->setAlwaysSearch($conf->getProperty(self::KEY_ALWAYS_SEARCH))->setAnonymousUsername($conf->getProperty(self::KEY_ANONYMOUS_USERNAME))->setAnonymousPassword(new PhutilOpaqueEnvelope($conf->getProperty(self::KEY_ANONYMOUS_PASSWORD)))->setActiveDirectoryDomain($conf->getProperty(self::KEY_ACTIVEDIRECTORY_DOMAIN));
         $this->adapter = $adapter;
     }
     return $this->adapter;
 }
Esempio n. 29
0
 protected function parseLinterOutput($path, $err, $stdout, $stderr)
 {
     $lines = phutil_split_lines($stderr, false);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         $match = preg_match('/^(?P<name>\\w+): (?P<description>.+) ' . 'in (?P<path>.+|-) ' . 'on line (?P<line>\\d+), column (?P<column>\\d+):$/', $line, $matches);
         if ($match) {
             switch ($matches['name']) {
                 case 'RuntimeError':
                     $code = self::LINT_RUNTIME_ERROR;
                     break;
                 case 'ArgumentError':
                     $code = self::LINT_ARGUMENT_ERROR;
                     break;
                 case 'FileError':
                     $code = self::LINT_FILE_ERROR;
                     break;
                 case 'NameError':
                     $code = self::LINT_NAME_ERROR;
                     break;
                 case 'OperationError':
                     $code = self::LINT_OPERATION_ERROR;
                     break;
                 case 'ParseError':
                     $code = self::LINT_PARSE_ERROR;
                     break;
                 case 'SyntaxError':
                     $code = self::LINT_SYNTAX_ERROR;
                     break;
                 default:
                     throw new RuntimeException(pht('Unrecognized lint message code "%s".', $code));
             }
             $code = $this->getLintCodeFromLinterConfigurationKey($matches['name']);
             $message = new ArcanistLintMessage();
             $message->setPath($path);
             $message->setLine($matches['line']);
             $message->setChar($matches['column']);
             $message->setCode($this->getLintMessageFullCode($code));
             $message->setSeverity($this->getLintMessageSeverity($code));
             $message->setName($this->getLintMessageName($code));
             $message->setDescription(ucfirst($matches['description']));
             $messages[] = $message;
         }
     }
     return $messages;
 }
 public function markupText($text, $children)
 {
     if ($this->getEngine()->isTextMode()) {
         $lines = rtrim($children, "\n");
         $lines = phutil_split_lines($lines);
         foreach ($lines as $key => $line) {
             if (isset($line[0]) && $line[0] == '>') {
                 $line = '>' . $line;
             } else {
                 $line = '> ' . $line;
             }
             $lines[$key] = $line;
         }
         return implode('', $lines);
     }
     return phutil_tag('blockquote', array(), $children);
 }