本文整理了Java中org.eclipse.jgit.api.Git.remoteAdd()
方法的一些代码示例,展示了Git.remoteAdd()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.remoteAdd()
方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:remoteAdd
[英]Return a command used to add a new remote.
[中]返回用于添加新远程设备的命令。
代码示例来源:origin: jphp-group/jphp
@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());
}
代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin
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);
}
}
代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin
/**
* @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);
}
}
}
代码示例来源:origin: Refactoring-Bot/Refactoring-Bot
/**
* 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!");
}
}
代码示例来源:origin: org.apache.camel/camel-git
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);
}
代码示例来源:origin: danielflower/app-runner
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);
}
}
代码示例来源:origin: synchrony/smsn
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());
}
}
代码示例来源:origin: Spirals-Team/repairnator
RemoteAddCommand remoteAdd = git.remoteAdd();
remoteAdd.setName(REMOTE_NAME);
remoteAdd.setUri(new URIish(remoteRepo));
代码示例来源:origin: Spirals-Team/repairnator
RemoteAddCommand remoteAddCommand = git.remoteAdd();
remoteAddCommand.setUri(new URIish(forkedRepo));
remoteAddCommand.setName("fork-patch");
代码示例来源:origin: Spirals-Team/repairnator
String remoteBranchPath = Utils.getCompleteGithubRepoUrl(prInformation.getOtherRepo().getFullName());
RemoteAddCommand remoteBranchCommand = git.remoteAdd();
remoteBranchCommand.setName("PR");
remoteBranchCommand.setUri(new URIish(remoteBranchPath));
内容来源于网络,如有侵权,请联系作者删除!