use of org.eclipse.jgit.transport.RemoteConfig in project jbosstools-openshift by jbosstools.
the class EGitUtilsTest method shouldFetchAndHaveRemoteRef.
@Test
public void shouldFetchAndHaveRemoteRef() throws Exception {
// given
testRepository.createAndCheckoutBranch(Constants.HEAD, REPO_BRANCH);
RemoteConfig remoteConfig = EGitUtils.getRemoteByName("origin", testRepositoryClone.getRepository());
String fullRef = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + REPO_BRANCH;
assertThat(testRepositoryClone.getRepository().findRef(fullRef), is(nullValue()));
// when
EGitUtils.fetch(remoteConfig, testRepositoryClone.getRepository(), new NullProgressMonitor());
// then
assertThat(testRepositoryClone.getRepository().findRef(fullRef), is(not(nullValue())));
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class BranchConfigurationDialog method addBranchItemsForRemote.
private void addBranchItemsForRemote(String remote) throws IOException, URISyntaxException {
RemoteConfig remoteConfig = new RemoteConfig(myConfig, remote);
List<RefSpec> fetchSpecs = remoteConfig.getFetchRefSpecs();
if (fetchSpecs.isEmpty()) {
return;
}
Collection<Ref> allRefs = myRepository.getRefDatabase().getRefs(Constants.R_REFS).values();
for (Ref ref : allRefs) {
for (RefSpec fetchSpec : fetchSpecs) {
// destination to source.
if (fetchSpec.matchDestination(ref)) {
RefSpec source = fetchSpec.expandFromDestination(ref);
String refNameOnRemote = source.getSource();
branchText.add(refNameOnRemote);
}
}
}
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class FetchWizard method saveConfig.
private void saveConfig() {
final RemoteConfig rc = repoPage.getSelection().getConfig();
rc.setFetchRefSpecs(refSpecPage.getRefSpecs());
rc.setTagOpt(refSpecPage.getTagOpt());
final StoredConfig config = localDb.getConfig();
rc.update(config);
try {
config.save();
} catch (final IOException e) {
ErrorDialog.openError(getShell(), UIText.FetchWizard_cantSaveTitle, UIText.FetchWizard_cantSaveMessage, new Status(IStatus.WARNING, Activator.getPluginId(), e.getMessage(), e));
// Continue, it's not critical.
}
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class SynchronizeViewPushTest method prepare.
@Before
public void prepare() throws Exception {
Repository childRepository = lookupRepository(childRepositoryFile);
Repository repository = lookupRepository(repositoryFile);
StoredConfig config = repository.getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
remoteConfig.addURI(new URIish(childRepository.getDirectory().getParentFile().toURI().toURL()));
remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
remoteConfig.update(config);
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REMOTE, "origin");
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_MERGE, "refs/heads/master");
config.save();
FetchOperation fetchOperation = new FetchOperation(repository, remoteConfig, 60, false);
fetchOperation.run(null);
}
use of org.eclipse.jgit.transport.RemoteConfig in project egit by eclipse.
the class GerritUtil method findRemoteConfig.
/**
* Find the remote config for the given remote name
*
* @param config
* the configuration containing the remote config
* @param remoteName
* the name of the remote to find
* @return the found remoteConfig or {@code null}
* @throws URISyntaxException
* if the configuration contains an illegal URI
*/
public static RemoteConfig findRemoteConfig(Config config, String remoteName) throws URISyntaxException {
RemoteConfig remoteConfig = null;
List<RemoteConfig> allRemoteConfigs = RemoteConfig.getAllRemoteConfigs(config);
for (RemoteConfig rc : allRemoteConfigs) {
if (rc.getName().equals(remoteName)) {
remoteConfig = rc;
break;
}
}
return remoteConfig;
}
Aggregations