本文整理了Java中org.eclipse.jgit.api.Git.remoteSetUrl()
方法的一些代码示例,展示了Git.remoteSetUrl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.remoteSetUrl()
方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:remoteSetUrl
[英]Return a command used to change the URL of an existing remote.
[中]返回用于更改现有远程服务器URL的命令。
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory remoteSetUrl(String name, String uri, boolean push) throws URISyntaxException, GitAPIException {
RemoteSetUrlCommand command = getWrappedObject().remoteSetUrl();
command.setName(name);
command.setUri(new URIish(uri));
command.setPush(push);
return GitUtils.valueOf(command.call());
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-contract-stub-runner
private Git cloneToBasedir(URI projectUrl, File destinationFolder) {
String url = projectUrl.toString();
String projectGitUrl = url.endsWith(".git") ? url : url + ".git";
if (log.isDebugEnabled()) {
log.debug("Project git url [" + projectGitUrl + "]");
}
CloneCommand command = this.gitFactory.getCloneCommandByCloneRepository()
.setURI(projectGitUrl).setDirectory(destinationFolder);
try {
Git git = command.call();
if (git.getRepository().getRemoteNames().isEmpty()) {
log.info("No remote added. Will add remote of the cloned project");
git.remoteSetUrl().setUri(new URIish(projectGitUrl));
git.remoteSetUrl().setName("origin");
git.remoteSetUrl().setPush(true);
}
return git;
}
catch (GitAPIException | URISyntaxException e) {
deleteBaseDirIfExists();
throw new IllegalStateException(e);
}
}
代码示例来源: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: berlam/github-bucket
@Override
public Status call() throws Exception {
LOG.info("Starting repository synchronization");
try (Git git = getWorkingFileRepository()) {
// Set fetch repo
config.configure(git.remoteSetUrl(), fetchUrl, false).call();
config.configure(git.remoteSetUrl(), pushRepository, true).call();
// Fetch repo
config.configure(git.fetch()).setCheckFetchedObjects(true).call();
// Push repo
config.configure(git.push()).setForce(true).call();
// Sync working tree
return pushRepository.call();
}
finally {
LOG.info("Finished repository synchronization");
// Close repository and free resources
config.getWorkingFileRepository().close();
}
}
内容来源于网络,如有侵权,请联系作者删除!