本文整理汇总了Java中org.eclipse.jgit.transport.RemoteConfig.update方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteConfig.update方法的具体用法?Java RemoteConfig.update怎么用?Java RemoteConfig.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.transport.RemoteConfig
的用法示例。
在下文中一共展示了RemoteConfig.update方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
workDir = getWorkingDirectory();
repository = getRepository(getLocalGitRepository());
otherWT = new File(workDir.getParentFile(), "repo2");
GitClient client = getClient(otherWT);
client.init(NULL_PROGRESS_MONITOR);
f = new File(otherWT, "f");
write(f, "init");
f2 = new File(otherWT, "f2");
write(f2, "init");
client.add(new File[] { f, f2 }, NULL_PROGRESS_MONITOR);
masterInfo = client.commit(new File[] { f, f2 }, "init commit", null, null, NULL_PROGRESS_MONITOR);
branch = client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
RemoteConfig cfg = new RemoteConfig(repository.getConfig(), "origin");
cfg.addURI(new URIish(otherWT.toURI().toURL().toString()));
cfg.update(repository.getConfig());
repository.getConfig().save();
}
示例2: setUp
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
workDir = getWorkingDirectory();
repository = getRepository(getLocalGitRepository());
otherWT = new File(workDir.getParentFile(), "repo2");
GitClient client = getClient(otherWT);
client.init(NULL_PROGRESS_MONITOR);
f = new File(otherWT, "f");
write(f, "init");
client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
masterInfo = client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
branch = client.createBranch(BRANCH_NAME, Constants.MASTER, NULL_PROGRESS_MONITOR);
RemoteConfig cfg = new RemoteConfig(repository.getConfig(), "origin");
cfg.addURI(new URIish(otherWT.toURI().toURL().toString()));
cfg.update(repository.getConfig());
repository.getConfig().save();
}
示例3: doOK
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
/**
* Adds the remote as origin to the repository
*/
@Override
protected void doOK() {
super.doOK();
StoredConfig config;
try {
config = GitAccess.getInstance().getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(remoteRepoTextField.getText());
remoteConfig.addURI(uri);
RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
remoteConfig.addFetchRefSpec(spec);
remoteConfig.update(config);
config.save();
} catch (NoRepositorySelected | URISyntaxException | IOException e) {
if (logger.isDebugEnabled()) {
logger.debug(e, e);
}
}
dispose();
}
示例4: testRemoteRepositoryHasNoCommitst
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
@Test(expected = MissingObjectException.class)
public void testRemoteRepositoryHasNoCommitst()
throws URISyntaxException, IOException, InvalidRemoteException, TransportException, GitAPIException, NoRepositorySelected {
gitAccess.setRepository(LOCAL_TEST_REPOSITPRY);
final StoredConfig config = gitAccess.getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(db2.getDirectory().toURI().toURL());
remoteConfig.addURI(uri);
remoteConfig.update(config);
config.save();
gitAccess.add(new FileStatus(GitChangeType.ADD, "test.txt"));
gitAccess.commit("file test added");
// throws missingObjectException
db2.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}");
}
示例5: testPushOK
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
@Test
public void testPushOK()
throws URISyntaxException, IOException, InvalidRemoteException, TransportException, GitAPIException, NoRepositorySelected {
gitAccess.setRepository(LOCAL_TEST_REPOSITPRY);
final StoredConfig config = gitAccess.getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(db2.getDirectory().toURI().toURL());
remoteConfig.addURI(uri);
remoteConfig.update(config);
config.save();
gitAccess.add(new FileStatus(GitChangeType.ADD, "test.txt"));
gitAccess.commit("file test added");
gitAccess.push("", "");
assertEquals(db1.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}"),
db2.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}"));
}
示例6: execute
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
public List<RefSpec> execute() throws IOException, URISyntaxException {
final List<RefSpec> specs = new ArrayList<>();
if (refSpecs == null || refSpecs.isEmpty()) {
specs.add(new RefSpec("+refs/heads/*:refs/remotes/" + remote.getK1() + "/*"));
specs.add(new RefSpec("+refs/tags/*:refs/tags/*"));
specs.add(new RefSpec("+refs/notes/*:refs/notes/*"));
} else {
specs.addAll(refSpecs);
}
final StoredConfig config = git.getRepository().getConfig();
final String url = config.getString("remote",
remote.getK1(),
"url");
if (url == null) {
final RemoteConfig remoteConfig = new RemoteConfig(git.getRepository().getConfig(),
remote.getK1());
remoteConfig.addURI(new URIish(remote.getK2()));
specs.forEach(remoteConfig::addFetchRefSpec);
remoteConfig.update(git.getRepository().getConfig());
git.getRepository().getConfig().save();
}
return specs;
}
示例7: testRemoveRemote
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
public void testRemoveRemote () throws Exception {
File otherWT = new File(workDir.getParentFile(), "repo2");
GitClient client = getClient(otherWT);
client.init(NULL_PROGRESS_MONITOR);
File f = new File(otherWT, "f");
write(f, "init");
client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
RemoteConfig cfg = new RemoteConfig(repository.getConfig(), "origin");
cfg.addURI(new URIish(otherWT.toURI().toURL().toString()));
cfg.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
cfg.update(repository.getConfig());
repository.getConfig().save();
client = getClient(workDir);
client.fetch("origin", NULL_PROGRESS_MONITOR);
client.createBranch("master", "origin/master", NULL_PROGRESS_MONITOR);
client.createBranch("nova", "origin/master", NULL_PROGRESS_MONITOR);
StoredConfig config = repository.getConfig();
assertEquals("+refs/heads/*:refs/remotes/origin/*", config.getString("remote", "origin", "fetch"));
assertEquals("origin", config.getString("branch", "master", "remote"));
assertEquals("refs/heads/master", config.getString("branch", "master", "merge"));
assertEquals("origin", config.getString("branch", "nova", "remote"));
assertEquals("refs/heads/master", config.getString("branch", "nova", "merge"));
// now try to remove the remote
client.removeRemote("origin", NULL_PROGRESS_MONITOR);
config = repository.getConfig();
config.load();
// is everything deleted?
assertEquals(0, config.getSubsections("remote").size());
assertNull(config.getString("branch", "master", "remote"));
assertNull(config.getString("branch", "master", "merge"));
assertNull(config.getString("branch", "nova", "remote"));
assertNull(config.getString("branch", "nova", "merge"));
}
示例8: testGetRemotes
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
public void testGetRemotes () throws Exception {
GitClient client = getClient(workDir);
StoredConfig cfg = repository.getConfig();
RemoteConfig remoteConfig = new RemoteConfig(cfg, "origin");
Map<String, GitRemoteConfig> remotes = client.getRemotes(NULL_PROGRESS_MONITOR);
assertEquals(0, remotes.size());
remoteConfig.update(cfg);
cfg.save();
remotes = client.getRemotes(NULL_PROGRESS_MONITOR);
assertEquals(0, remotes.size());
remoteConfig.addURI(new URIish("file:///home/repository"));
remoteConfig.addURI(new URIish("file:///home/repository2"));
remoteConfig.addPushURI(new URIish("file:///home/repository"));
remoteConfig.addPushURI(new URIish("file:///home/repository3"));
remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/master:refs/remotes/origin/my-master"));
remoteConfig.addPushRefSpec(new RefSpec("refs/remotes/origin/*:refs/heads/*"));
remoteConfig.update(cfg);
cfg.save();
remotes = client.getRemotes(NULL_PROGRESS_MONITOR);
assertEquals(1, remotes.size());
assertEquals("origin", remotes.get("origin").getRemoteName());
assertEquals(Arrays.asList(new String[] { "file:///home/repository", "file:///home/repository2" }), remotes.get("origin").getUris());
assertEquals(Arrays.asList(new String[] { "file:///home/repository", "file:///home/repository3" }), remotes.get("origin").getPushUris());
assertEquals(Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*", "+refs/heads/master:refs/remotes/origin/my-master" }), remotes.get("origin").getFetchRefSpecs());
assertEquals(Arrays.asList(new String[] { "refs/remotes/origin/*:refs/heads/*" }), remotes.get("origin").getPushRefSpecs());
GitRemoteConfig remote = client.getRemote("origin", NULL_PROGRESS_MONITOR);
assertEquals("origin", remote.getRemoteName());
assertEquals(Arrays.asList(new String[] { "file:///home/repository", "file:///home/repository2" }), remote.getUris());
assertEquals(Arrays.asList(new String[] { "file:///home/repository", "file:///home/repository3" }), remote.getPushUris());
assertEquals(Arrays.asList(new String[] { "+refs/heads/*:refs/remotes/origin/*", "+refs/heads/master:refs/remotes/origin/my-master" }), remote.getFetchRefSpecs());
assertEquals(Arrays.asList(new String[] { "refs/remotes/origin/*:refs/heads/*" }), remote.getPushRefSpecs());
}
示例9: testNoPushesAhead
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
@Test
public void testNoPushesAhead() throws RepositoryNotFoundException, IOException, URISyntaxException, NoRepositorySelected, InvalidRemoteException, TransportException, GitAPIException{
gitAccess.setRepository(LOCAL_TEST_REPOSITPRY);
final StoredConfig config = gitAccess.getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(db2.getDirectory().toURI().toURL());
remoteConfig.addURI(uri);
remoteConfig.update(config);
config.save();
int actual = gitAccess.getPushesAhead();
int expected = 0;
assertEquals(expected, actual);
}
示例10: bindLocalToRemote
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
/**
* Binds the local repository to the remote one.
*
* @param localRepository The local repository.
* @param remoteRepo The remote repository.
*
* @throws NoRepositorySelected
* @throws URISyntaxException
* @throws MalformedURLException
* @throws IOException
*/
protected void bindLocalToRemote(Repository localRepository, Repository remoteRepo)
throws NoRepositorySelected, URISyntaxException, MalformedURLException, IOException {
StoredConfig config = localRepository.getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(remoteRepo.getDirectory().toURI().toURL());
remoteConfig.addURI(uri);
RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
remoteConfig.addFetchRefSpec(spec);
remoteConfig.update(config);
config.save();
remoteRepos.add(remoteRepo);
}
示例11: setRemoteUrl
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
private void setRemoteUrl(Repository repository, URIish uri) throws IOException {
RemoteConfig remoteConfig = remoteConfigFor(repository, DEFAULT_REMOTE_NAME);
for (URIish urIish : remoteConfig.getURIs()) {
remoteConfig.removeURI(urIish);
}
remoteConfig.addURI(uri);
remoteConfig.update(repository.getConfig());
repository.getConfig().save();
}
示例12: setupRemoteSpec
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
private void setupRemoteSpec (String remote, String fetchSpec) throws URISyntaxException, IOException {
RemoteConfig cfg = new RemoteConfig(repository.getConfig(), remote);
cfg.addFetchRefSpec(new RefSpec(fetchSpec));
cfg.update(repository.getConfig());
repository.getConfig().save();
}
示例13: before
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
public void before(Description description) throws IOException, GitAPIException, URISyntaxException, InterruptedException {
String repoName = description.getClassName() + "-" + description.getMethodName();
assertThat("Specify GH_TOKEN variable", GH_TOKEN, notNullValue());
//reuse github client for GitHub preparation
gitHubServerConfig = prepareGitHubPlugin();
//FIXME no idea why github-plugin doesn't find configuration without delay, try delay
await().timeout(20, SECONDS)
.until(ghAppeared(gitHubServerConfig));
gitHub = loginToGithub().apply(gitHubServerConfig);
assertThat("Specify right GH_TOKEN variable!", gitHub, notNullValue());
LOG.debug(gitHub.getRateLimit().toString());
ghRepo = gitHub.getMyself().getRepository(repoName);
if (ghRepo != null) {
LOG.info("Deleting {}", ghRepo.getHtmlUrl());
ghRepo.delete();
await().pollInterval(3, SECONDS)
.timeout(120, SECONDS)
.until(ghRepoDeleted(gitHub, ghRepo.getFullName()));
}
ghRepo = gitHub.createRepository(repoName, "", "", true);
LOG.info("Created {}", ghRepo.getHtmlUrl());
await().pollInterval(2, SECONDS)
.timeout(120, SECONDS)
.until(ghRepoAppeared(gitHub, ghRepo.getFullName()));
// prepare git
gitRootDir = temporaryFolder.newFolder();
git = Git.init().setDirectory(gitRootDir).call();
writeStringToFile(new File(gitRootDir, "README.md"), "Test repo");
git.add().addFilepattern(".").call();
git.commit().setAll(true).setMessage("Initial commit").call();
final RefSpec refSpec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
final StoredConfig storedConfig = git.getRepository().getConfig();
final RemoteConfig origin = new RemoteConfig(storedConfig, "origin");
origin.addURI(new URIish(ghRepo.gitHttpTransportUrl()));
origin.addPushRefSpec(refSpec);
origin.update(storedConfig);
storedConfig.save();
commitFileToBranch(BRANCH1, BRANCH1 + ".file", "content", "commit for " + BRANCH1);
commitFileToBranch(BRANCH2, BRANCH2 + ".file", "content", "commit for " + BRANCH2);
git.checkout().setName("master").call();
pushAll();
}
示例14: doExecute
import org.eclipse.jgit.transport.RemoteConfig; //导入方法依赖的package包/类
@Override
protected void doExecute() {
try {
StoredConfig config = git.getRepository().getConfig();
List<RemoteConfig> remoteConfigs = RemoteConfig.getAllRemoteConfigs(config);
if (remoteConfigs.isEmpty()) {
URIish uri = new URIish(getUri());
RemoteConfig remoteConfig = new RemoteConfig(config, Constants.DEFAULT_REMOTE_NAME);
remoteConfig.addURI(uri);
remoteConfig.addFetchRefSpec(new RefSpec(DEFAULT_REFSPEC_STRING));
remoteConfig.addPushRefSpec(new RefSpec(DEFAULT_REFSPEC_STRING));
remoteConfig.update(config);
config.save();
}
String currentBranch = git.getRepository().getBranch();
List<RefSpec> specs = Arrays.asList(new RefSpec(currentBranch + ":" + currentBranch));
PushCommand pushCommand = git.push().
setPushAll().
setRefSpecs(specs).
setDryRun(false).
setRemote(getUri());
setupCredentials(pushCommand);
if (includeTags) {
pushCommand.setPushTags();
}
if (getProgressMonitor() != null) {
pushCommand.setProgressMonitor(getProgressMonitor());
}
Iterable<PushResult> pushResults = pushCommand.setForce(true).call();
for (PushResult pushResult : pushResults) {
GitTaskUtils.validateTrackingRefUpdates(PUSH_FAILED_MESSAGE, pushResult.getTrackingRefUpdates());
log(pushResult.getMessages());
}
} catch (Exception e) {
if (pushFailedProperty != null) {
getProject().setProperty(pushFailedProperty, e.getMessage());
}
throw new GitBuildException(PUSH_FAILED_MESSAGE, e);
}
}