note() public method

public note ( $message )
コード例 #1
0
ファイル: GitHubConfigurator.php プロジェクト: gushphp/gush
 private function handle2fa(Client $client, TwoFactorAuthenticationRequiredException $e)
 {
     $authenticationAttempts = 0;
     $authorization = [];
     $type = trim($e->getType());
     // Stupid API gives text with spaces
     $message = ['Username and password were correct.', 'Two factor authentication is required to continue authentication.'];
     if ('app' === $type) {
         $message[] = 'Open the two-factor authentication app on your device to view your authentication code and verify your identity.';
     } elseif ('sms' === $type) {
         $message[] = 'You have been sent an SMS message with an authentication code to verify your identity.';
     }
     $this->styleHelper->note($message);
     // We already know the password is valid, we just need a valid code
     // Don't want to fill in everything again when you know it's valid ;)
     while (!isset($authorization['token'])) {
         if ($authenticationAttempts > 0) {
             $this->styleHelper->error('Two factor authentication code was invalid, please try again.');
         }
         try {
             $code = $this->styleHelper->ask('Two factor authentication code', null, [$this, 'validateNoneEmpty']);
             $authorization = $this->createAuthorization($client, $code);
         } catch (TwoFactorAuthenticationRequiredException $e) {
             // No-op, continue the loop, try again
         } catch (\Exception $e) {
             $this->styleHelper->error($e->getMessage());
             $this->styleHelper->newLine();
         }
         ++$authenticationAttempts;
     }
     return $authorization;
 }
コード例 #2
0
 private function guardRemoteBranchExist($org, $repo, $branch, StyleHelper $styleHelper)
 {
     /** @var GitHelper $gitHelper */
     $gitHelper = $this->getHelper('git');
     $gitUrl = $this->getAdapter()->getRepositoryInfo($org, $repo)['push_url'];
     if ($gitHelper->remoteBranchExists($gitUrl, $branch)) {
         return;
         // branch exists, continue
     }
     if ($gitHelper->branchExists($branch)) {
         $this->guardRemoteUpdated($org, $repo);
         $gitHelper->pushToRemote($org, $branch, true);
         $styleHelper->note(sprintf('Branch "%s" was pushed to "%s".', $branch, $org));
         return;
     }
     throw new UserException(sprintf('Cannot open pull-request, remote branch "%s" does not exist in "%s/%s".', $branch, $org, $repo));
 }