Exemplo n.º 1
0
 public static function addSshAliasLines(array &$sshConfigLines, $repository, RepositoryConfiguration $repositoryConfig)
 {
     $repoParts = Util::parseRepositoryUrl($repository);
     $newConfigLines = ['Host ' . $repositoryConfig->getSshAlias(), 'HostName ' . $repoParts['host'], 'User ' . $repoParts['user'], 'IdentityFile ' . $repositoryConfig->getIdentityFile()];
     $foundAliasLines = self::findSshAliasLines($sshConfigLines, $repositoryConfig->getSshAlias());
     if (!$foundAliasLines) {
         $sshConfigLines = array_merge($sshConfigLines, $newConfigLines);
         return true;
     } else {
         $presentAliasLines = array_map(function ($i) use($sshConfigLines) {
             return $sshConfigLines[$i];
         }, $foundAliasLines);
         foreach ($newConfigLines as $newConfigLine) {
             if (!in_array($newConfigLine, $presentAliasLines)) {
                 throw new SshAliasExistsException($repositoryConfig->getSshAlias(), $foundAliasLines[0]);
             }
         }
         return false;
     }
 }