getStatus() public method

A path1.txt M path2.txt Clean working directory returns an empty string.
public getStatus ( $array = false ) : string | array[string]
$array bool Return result as array
return string | array[string]
Ejemplo n.º 1
0
 /**
  * Creates manual commit. Adds everything to stage.
  *
  * @param WP_REST_Request $request
  * @return WP_REST_Response|\WP_Error
  */
 public function commit(WP_REST_Request $request)
 {
     $currentUser = wp_get_current_user();
     if ($currentUser->ID === 0) {
         return new \WP_Error('error', 'You don\'t have permission to do this.', array('status' => 403));
     }
     /** @noinspection PhpUndefinedFieldInspection */
     $authorName = $currentUser->display_name;
     /** @noinspection PhpUndefinedFieldInspection */
     $authorEmail = $currentUser->user_email;
     $this->gitRepository->stageAll();
     $status = $this->gitRepository->getStatus(true);
     if (ArrayUtils::any($status, function ($fileStatus) {
         return Strings::contains($fileStatus[1], 'vpdb');
     })) {
         $this->updateDatabase($status);
     }
     $this->gitRepository->commit($request['commit-message'], $authorName, $authorEmail);
     return new WP_REST_Response(true);
 }
Ejemplo n.º 2
0
 /**
  * Creates manual commit. Adds everything to stage.
  *
  * @param WP_REST_Request $request
  * @return WP_REST_Response|WP_Error
  */
 public function commit(WP_REST_Request $request)
 {
     $currentUser = wp_get_current_user();
     if ($currentUser->ID === 0) {
         return new WP_Error('error', 'You don\'t have permission to do this.', ['status' => 403]);
     }
     /** @noinspection PhpUndefinedFieldInspection */
     $authorName = $currentUser->display_name;
     /** @noinspection PhpUndefinedFieldInspection */
     $authorEmail = $currentUser->user_email;
     $this->gitRepository->stageAll();
     $status = $this->gitRepository->getStatus(true);
     if (ArrayUtils::any($status, function ($fileStatus) {
         $vpdbName = basename(VP_VPDB_DIR);
         return Strings::contains($fileStatus[1], $vpdbName);
     })) {
         $this->updateDatabase($status);
     }
     $commitMessage = new CommitMessage($request['commit-message']);
     $changeInfoEnvelope = new ChangeInfoEnvelope([new UntrackedChangeInfo($commitMessage)]);
     $this->gitRepository->commit($changeInfoEnvelope->getCommitMessage(), $authorName, $authorEmail);
     return new WP_REST_Response(true);
 }