@Signature public Memory remoteAdd(String name, String uri) throws URISyntaxException, GitAPIException { RemoteAddCommand command = getWrappedObject().remoteAdd(); command.setName(name); command.setUri(new URIish(uri)); return GitUtils.valueOf(command.call()); }
private void addRemote(Git git, String name, String uri) { RemoteAddCommand remoteAdd = git.remoteAdd(); remoteAdd.setName(name); try { remoteAdd.setUri(new URIish(uri)); } catch (URISyntaxException e) { throw new IllegalStateException(e); } try { remoteAdd.call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
/** * @inheritDoc */ @Override public void addRemoteUpstream(Git git, String path) throws Exception { if (!isUpstreamRepoCreated(git, path)) { try { RemoteAddCommand remoteAddCommand = git.remoteAdd(); remoteAddCommand.setUri(new URIish(getRemoteRepoUrlFromPom(path))); remoteAddCommand.setName(UPSTREAM); remoteAddCommand.call(); } catch (URISyntaxException e) { throw new Exception(CREATING_URL_FROM_POM_REASON, e); } catch (MojoExecutionException e) { throw new MojoExecutionException(NO_GIT_PROJECT_FOUND_REASON, e); } catch (GitAPIException e) { throw new Exception(CREATING_REMOTE_UPSTREAM_REASON, e); } } }
/** * This method adds an Remote to the fork/bot-repository. * * @param gitConfig * @throws GitWorkflowException */ public void addRemote(GitConfiguration gitConfig) throws GitWorkflowException { try (Git git = Git.open(new File(botConfig.getBotRefactoringDirectory() + gitConfig.getConfigurationId()))) { // Add Remote as 'upstream' RemoteAddCommand remoteAddCommand = git.remoteAdd(); remoteAddCommand.setName("upstream"); remoteAddCommand.setUri(new URIish(gitConfig.getRepoGitLink())); remoteAddCommand.call(); } catch (Exception e) { logger.error(e.getMessage(), e); throw new GitWorkflowException( "Could not add as remote " + "'" + gitConfig.getRepoGitLink() + "' successfully!"); } }
protected void doRemoteAdd(Exchange exchange, String operation) throws Exception { if (ObjectHelper.isEmpty(endpoint.getRemoteName())) { throw new IllegalArgumentException("Remote Name must be specified to execute " + operation); } if (ObjectHelper.isEmpty(endpoint.getRemotePath())) { throw new IllegalArgumentException("Remote Path must be specified to execute " + operation); } RemoteConfig result = null; try { RemoteAddCommand remoteAddCommand = git.remoteAdd(); remoteAddCommand.setUri(new URIish(endpoint.getRemotePath())); remoteAddCommand.setName(endpoint.getRemoteName()); result = remoteAddCommand.call(); } catch (Exception e) { LOG.error("There was an error in Git {} operation", operation); throw e; } updateExchange(exchange, result); }
public static BackupService prepare(File localDir, URIish remoteUri, int backupTimeInMinutes) throws GitAPIException, IOException { Git local; try { local = Git.open(localDir); } catch (RepositoryNotFoundException e) { log.info("Initialising " + fullPath(localDir) + " as a git repo for backup purposes"); local = Git.init().setDirectory(localDir).setBare(false).call(); } log.info("Setting backup URL to " + remoteUri); if (local.remoteList().call().stream().anyMatch(remoteConfig -> remoteConfig.getName().equals("origin"))) { RemoteSetUrlCommand remoteSetUrlCommand = local.remoteSetUrl(); remoteSetUrlCommand.setName("origin"); remoteSetUrlCommand.setUri(remoteUri); remoteSetUrlCommand.call(); } else { RemoteAddCommand remoteAddCommand = local.remoteAdd(); remoteAddCommand.setName("origin"); remoteAddCommand.setUri(remoteUri); remoteAddCommand.call(); } URL inputUrl = BackupService.class.getResource("/dataDirGitIgnore.txt"); FileUtils.copyURLToFile(inputUrl, new File(localDir, ".gitignore")); return new BackupService(local, remoteUri.toString(), backupTimeInMinutes); } }
private void addOrigin() throws URISyntaxException, GitAPIException { RemoteAddCommand add = git.remoteAdd(); add.setName("origin"); String uri = "https://example.org/repo"; add.setUri(new URIish(uri)); add.call(); assertEquals("origin", git.remoteList().call().iterator().next().getName()); assertEquals(uri, git.remoteList().call().iterator().next().getURIs().iterator().next().toString()); } }
RemoteAddCommand remoteAdd = git.remoteAdd(); remoteAdd.setName(REMOTE_NAME); remoteAdd.setUri(new URIish(remoteRepo));
RemoteAddCommand remoteAddCommand = git.remoteAdd(); remoteAddCommand.setUri(new URIish(forkedRepo)); remoteAddCommand.setName("fork-patch");
String remoteBranchPath = Utils.getCompleteGithubRepoUrl(prInformation.getOtherRepo().getFullName()); RemoteAddCommand remoteBranchCommand = git.remoteAdd(); remoteBranchCommand.setName("PR"); remoteBranchCommand.setUri(new URIish(remoteBranchPath));