Exemplo n.º 1
0
 public function do_execute()
 {
     /* Prepare variables */
     try {
         $project_id = $this->getProvidedArgument('projectid');
         $project_row = \thebuggenie\core\entities\tables\Projects::getTable()->getById($project_id, false);
         \thebuggenie\core\framework\Context::setScope(new \thebuggenie\core\entities\Scope($project_row[\thebuggenie\core\entities\tables\Projects::SCOPE]));
         $project = new \thebuggenie\core\entities\Project($project_id, $project_row);
     } catch (\Exception $e) {
         $this->cliEcho("The project with the ID " . $this->getProvidedArgument('projectid') . " does not exist\n", 'red', 'bold');
         exit;
     }
     $author = $this->getProvidedArgument('author');
     $new_rev = $this->getProvidedArgument('revno');
     $commit_msg = $this->getProvidedArgument('log');
     $changed = $this->getProvidedArgument('changed');
     $old_rev = $this->getProvidedArgument('oldrev', null);
     $date = $this->getProvidedArgument('date', null);
     $branch = $this->getProvidedArgument('branch', null);
     if (\thebuggenie\core\framework\Settings::get('access_method_' . $project->getKey()) == Vcs_integration::ACCESS_HTTP) {
         $this->cliEcho("This project uses the HTTP access method, and so access via the CLI has been disabled\n", 'red', 'bold');
         exit;
     }
     if ($old_rev === null && !ctype_digit($new_rev)) {
         $this->cliEcho("Error: if only the new revision is specified, it must be a number so that old revision can be calculated from it (by substracting 1 from new revision number).");
     } else {
         if ($old_rev === null) {
             $old_rev = $new_rev - 1;
         }
     }
     $output = Vcs_integration::processCommit($project, $commit_msg, $old_rev, $new_rev, $date, $changed, $author, $branch);
     $this->cliEcho($output);
 }
Exemplo n.º 2
0
 public function runAddCommitGitorious(framework\Request $request)
 {
     framework\Context::getResponse()->setContentType('text/plain');
     framework\Context::getResponse()->renderHeaders();
     $passkey = framework\Context::getRequest()->getParameter('passkey');
     $project_id = framework\Context::getRequest()->getParameter('project_id');
     $project = Project::getB2DBTable()->selectByID($project_id);
     // Validate access
     if (!$project) {
         echo 'Error: The project with the ID ' . $project_id . ' does not exist';
         exit;
     }
     if (framework\Settings::get('access_method_' . $project->getID(), 'vcs_integration') == Vcs_integration::ACCESS_DIRECT) {
         echo 'Error: This project uses the CLI access method, and so access via HTTP has been disabled';
         exit;
     }
     if (framework\Settings::get('access_passkey_' . $project->getID(), 'vcs_integration') != $passkey) {
         echo 'Error: The passkey specified does not match the passkey specified for this project';
         exit;
     }
     // Validate data
     $data = html_entity_decode(framework\Context::getRequest()->getParameter('payload', null, false));
     if (empty($data) || $data == null) {
         die('Error: No payload was provided');
     }
     $entries = json_decode($data);
     if ($entries == null) {
         die('Error: The payload could not be decoded');
     }
     $entries = json_decode($data);
     $previous = $entries->before;
     // Branch is stored in the ref
     $ref = $entries->ref;
     $parts = explode('/', $ref);
     if (count($parts) == 3) {
         $branch = $parts[2];
     } else {
         $branch = null;
     }
     // Parse each commit individually
     foreach (array_reverse($entries->commits) as $commit) {
         $email = $commit->author->email;
         $author = $commit->author->name;
         $new_rev = $commit->id;
         $old_rev = $previous;
         $commit_msg = $commit->message;
         $time = strtotime($commit->timestamp);
         // Add commit
         echo Vcs_integration::processCommit($project, $commit_msg, $old_rev, $previous, $time, "", $author, $branch);
         $previous = $new_rev;
         exit;
     }
 }