public function Run() { $filepath = "{$this->root}/{$this->get['filepath']}"; $tmpfname = tempnam("/tmp", "shipshape-results-"); $fp = fopen($tmpfname, "w"); fclose($fp); $ret = runShellCommand("shipshape --categories='go vet,JSHint,PyLint' --json_output={$tmpfname}" . " {$this->escapeShellArg($filepath)}"); echo formatJSEND('success', json_decode(file_get_contents($tmpfname))); unlink($tmpfname); }
public function Run() { $filepath = "{$this->root}/{$this->get['filepath']}"; // Truncate the output json file. $fp = fopen("/tmp/shipshape-results.json", "w"); fclose($fp); $ret = runShellCommand("shipshape --categories='go vet,JSHint,PyLint'" . " --json_output=/tmp/shipshape-results.json" . " {$this->escapeShellArg($filepath)}"); if ($ret->exit_code != 0) { // If for any reason shipshape command failed, we don't want to show error message. // The reason could be simply that there is no reference at the requested position. echo formatJSEND('success', 'Running shipshape failed.'); return; } echo formatJSEND('success', json_decode(file_get_contents('/tmp/shipshape-results.json'))); }
public function GetLocalRefs() { $filepath = $this->escapeShellArg(str_replace($this->project . '/', '', $this->get['filepath'])); $fileTicket = $this->escapeShellArg($this->GetFileTicket($filepath)); $dirtyBuffer = $this->escapeShellArg("{$this->root}/{$this->get['filepath']}"); $cursor = $this->get['cursor']; $ret = runShellCommand("/opt/kythe/tools/kythe --json" . " -api http://localhost:" . KYTHE_SERVER_PORT . " refs --dirty {$dirtyBuffer} {$fileTicket}"); if ($ret->exit_code != 0 || count($ret->output) == 0) { // If for any reason kythe command failed, we don't want to show error message. // The reason could be simply that there is no reference at the requested position. echo formatJSEND('success'); return; } $kythe_refs = json_decode($ret->output[0]); // Go through the kythe's response and build three maps which are addressable by tickets. $refs_target = array(); $refs_source = array(); $nodes = array(); $matchedLocationTickets = array(); foreach ($kythe_refs->reference as $reference) { if (!isset($refs_target[$reference->target_ticket])) { $refs_target[$reference->target_ticket] = array(); } if (!isset($refs_source[$reference->source_ticket])) { $refs_source[$reference->source_ticket] = array(); } $refs_target[$reference->target_ticket][] = $reference; $refs_source[$reference->source_ticket][] = $reference; } foreach ($kythe_refs->node as $node) { $nodes[$node->ticket] = $node; if ($this->LocationMatches($node, $cursor)) { $matchedLocationTickets[] = $refs_source[$node->ticket][0]->target_ticket; } } $ref_locations = array(); // Go through all the nodes in the file. If the location of the node // matches that of the cursor, then use the node's ticket to find all of // the references which target ticket is the same as node's ticket. // For those references get the location of the nodes whose tickets are // the same as the reference's source. foreach ($matchedLocationTickets as $t) { foreach ($refs_target[$t] as $target_ref) { $ref_locations[] = $this->GetLocation($nodes[$target_ref->source_ticket]); } } echo formatJSEND('success', $ref_locations); }
public function ListBranches() { $repo = Common::GetProjectRoot(); $ret = runShellCommand("git -C {$this->escapeShellArg($repo)} branch --no-color " . " | awk -F ' +' '! /\\(no branch\\)/ {print \$2}' "); if ($ret->exit_code != 0 || count($ret->output) == 0) { echo formatJSEND('error', 'No branches in this project.'); return; } $branches = $ret->output; $currentBranch = $this->GetCurrentBranchName(); $result = new stdClass(); $result->current_branch = trim($currentBranch); $result->branches = $branches; echo formatJSEND('success', $result); }
public static function RunGitCommand($command) { $repo = escapeshellarg(Common::GetProjectRoot()); return runShellCommand("git -C {$repo} {$command} 2>&1"); }
<div id="filemanager-search-results"></div> <div id="filemanager-search-processing"></div> <button class="codiad "><?php i18n("Find"); ?> </button> <button class="codiad " onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?> </button> </form> <?php break; case 'list_all_files': $repo = Common::escapeShellArg(Common::GetProjectRoot()); $ret = runShellCommand("find {$repo} -type f -not -iwholename '*.git/*' " . " -follow -printf '%P\\n' | sort"); ?> <form> <div id="search-file-box"> <select data-placeholder="Choose a file..." class="chosen-file-select"> <option value=""></option> <?php foreach ($ret->output as $f) { ?> <option value="<?php echo $f; ?> "><?php echo $f; ?> </option><?php