List of usage examples for org.eclipse.jgit.transport URIish equals
@Override public boolean equals(Object obj)
From source file:com.cloudbees.eclipse.dev.scm.egit.ForgeEGitSync.java
License:Open Source License
public static boolean isAlreadyCloned(final String url) { try {// ww w .jav a 2s .co m if (url == null) { return false; } String bareUrl = ForgeUtil.stripGitPrefixes(url); if (bareUrl == null) { return false; } URIish proposalHTTPS = new URIish(ForgeUtil.PR_HTTPS + bareUrl); URIish proposalSSH = new URIish(ForgeUtil.PR_SSH + bareUrl); List<String> reps = Activator.getDefault().getRepositoryUtil().getConfiguredRepositories(); for (String repo : reps) { try { FileRepository fr = new FileRepository(new File(repo)); List<RemoteConfig> allRemotes = RemoteConfig.getAllRemoteConfigs(fr.getConfig()); for (RemoteConfig remo : allRemotes) { List<URIish> uris = remo.getURIs(); for (URIish uri : uris) { //System.out.println("Checking URI: " + uri + " - " + proposal.equals(uri)); if (proposalHTTPS.equals(uri) || proposalSSH.equals(uri)) { return true; } } } } catch (Exception e) { CloudBeesCorePlugin.getDefault().getLogger().error(e); } } } catch (Exception e) { CloudBeesCorePlugin.getDefault().getLogger().error(e); } return false; }
From source file:com.cloudbees.eclipse.dev.scm.egit.ForgeEGitSync.java
License:Open Source License
private boolean openRemoteFile_(final String repo, final ChangeSetPathItem item, final IProgressMonitor monitor) { try {//from w w w.ja va 2 s . c o m // TODO extract repo search into separate method RepositoryCache repositoryCache = org.eclipse.egit.core.Activator.getDefault().getRepositoryCache(); Repository repository = null; URIish proposal = new URIish(repo); List<String> reps = Activator.getDefault().getRepositoryUtil().getConfiguredRepositories(); all: for (String rep : reps) { try { Repository fr = repositoryCache.lookupRepository(new File(rep)); List<RemoteConfig> allRemotes = RemoteConfig.getAllRemoteConfigs(fr.getConfig()); for (RemoteConfig remo : allRemotes) { List<URIish> uris = remo.getURIs(); for (URIish uri : uris) { CloudBeesDevCorePlugin.getDefault().getLogger() .info("Checking URI: " + uri + " - " + proposal.equals(uri)); if (proposal.equals(uri)) { repository = fr; break all; } } } } catch (Exception e) { CloudBeesDevCorePlugin.getDefault().getLogger().error(e); } } CloudBeesDevCorePlugin.getDefault().getLogger().info("Repo: " + repository); if (repository == null) { throw new CloudBeesException("Failed to find mapped repository for " + repo); } ObjectId commitId = ObjectId.fromString(item.parent.id); RevWalk rw = new RevWalk(repository); RevCommit rc = rw.parseCommit(commitId); final IFileRevision rev = CompareUtils.getFileRevision(item.path, rc, repository, null); final IEditorPart[] editor = new IEditorPart[1]; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { IWorkbenchPage activePage = CloudBeesUIPlugin.getActiveWindow().getActivePage(); try { editor[0] = Utils.openEditor(activePage, rev, monitor); } catch (CoreException e) { e.printStackTrace(); // TODO } } }); return editor[0] != null; } catch (Exception e) { CloudBeesDevCorePlugin.getDefault().getLogger().error(e); // TODO handle better? return false; } }
From source file:edu.tum.cs.mylyn.internal.provisioning.git.UniqueInMemoryRepository.java
License:Open Source License
@Override public boolean equals(Object obj) { if (obj == null) { return false; }//from ww w .java 2 s . c om if (obj == this) { return true; } if (!(obj instanceof UniqueInMemoryRepository)) { return false; } URIish cloneUri = GitProvisioningUtil.getCloneUri(this); URIish otherCloneUri = GitProvisioningUtil.getCloneUri((Repository) obj); if (cloneUri == null || otherCloneUri == null) { return false; } return cloneUri.equals(otherCloneUri); }
From source file:edu.tum.cs.mylyn.provisioning.git.ui.GitProvisioningTask.java
License:Open Source License
private List<RepositoryWrapper> getRequiredRepositories(ProvisioningContext context) { List<RepositoryWrapper> results = new ArrayList<RepositoryWrapper>(); RepositoryCache repositoryCache = org.eclipse.egit.core.Activator.getDefault().getRepositoryCache(); for (ProvisioningElement element : context.getProvisioningElements(GitContributor.CONTENT_TYPE)) { Object object = context.getObject(element); if (object instanceof RepositoryWrapper) { RepositoryWrapper repository = (RepositoryWrapper) object; boolean required = true; for (Repository knownRepository : repositoryCache.getAllRepositories()) { URIish knownRepositoryUri = GitProvisioningUtil.getCloneUri(knownRepository); URIish cloneURI = repository.getCloneURI(); if (knownRepositoryUri.equals(cloneURI)) { required = false;// w ww . ja va 2 s .c o m break; } } if (required) { results.add(repository); } } } return results; }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.agent.UpdaterImpl.java
License:Apache License
private void validateUrls() { URIish fetch = myRoot.getRepositoryFetchURL(); if (isAnonymousGitWithUsername(fetch)) LOG.warn("Fetch URL '" + fetch.toString() + "' for root " + myRoot.getName() + " uses an anonymous git protocol and contains a username, fetch will probably fail"); URIish push = myRoot.getRepositoryPushURL(); if (!fetch.equals(push) && isAnonymousGitWithUsername(push)) LOG.warn("Push URL '" + push.toString() + "'for root " + myRoot.getName() + " uses an anonymous git protocol and contains a username, push will probably fail"); }
From source file:org.eclipse.egit.core.internal.ProjectReferenceImporter.java
License:Open Source License
private static boolean containsRemoteForUrl(Config config, URIish url) throws URISyntaxException { Set<String> remotes = config.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION); for (String remote : remotes) { String remoteUrl = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION, remote, ConfigConstants.CONFIG_KEY_URL); URIish existingUrl = new URIish(remoteUrl); if (existingUrl.equals(url)) return true; }/* w w w. j av a2 s .c o m*/ return false; }
From source file:org.eclipse.egit.ui.internal.repository.ConfigureUriPage.java
License:Open Source License
public void createControl(Composite parent) { Composite main = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(main); if (myFetchMode) { main.setLayout(new GridLayout(3, false)); // we only use the first URI Label uriLabel = new Label(main, SWT.NONE); uriLabel.setText(UIText.ConfigureUriPage_FetchUri_label); uriLabel.setToolTipText(UIText.ConfigureUriPage_UriTooltip); uriText = new Text(main, SWT.BORDER); // manual entry is dangerous, as the validate may wait forever uriText.setEnabled(false);//from ww w . j ava 2 s . c om Button change = new Button(main, SWT.PUSH); change.setText(UIText.ConfigureUriPage_Change_button); change.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SelectUriWizard slwz = new SelectUriWizard(false, uriText.getText()); WizardDialog dlg = new WizardDialog(getShell(), slwz); dlg.setHelpAvailable(false); if (dlg.open() == Window.OK) { URIish uri = slwz.getUri(); credentials = slwz.getCredentials(); uriText.setText(uri.toPrivateString()); checkPage(); } } }); if (myConfig != null && !myConfig.getURIs().isEmpty()) { uriText.setText(myConfig.getURIs().get(0).toPrivateString()); checkPage(); } else { setPageComplete(false); } GridDataFactory.fillDefaults().grab(true, false).applyTo(uriText); } else { main.setLayout(new GridLayout(2, false)); Label uriLabel = new Label(main, SWT.NONE); uriLabel.setText(UIText.ConfigureUriPage_FetchUri_label); uriLabel.setToolTipText(UIText.ConfigureUriPage_UriTooltip); uriText = new Text(main, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(uriText); // push mode, display only uriText.setEnabled(false); Label pushLabel = new Label(main, SWT.NONE); pushLabel.setText(UIText.ConfigureUriPage_PushUriLabel); pushLabel.setToolTipText(UIText.ConfigureUriPage_PushUriTooltip); GridDataFactory.fillDefaults().span(2, 1).applyTo(pushLabel); tv = new TableViewer(main); GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(tv.getTable()); tv.setLabelProvider(new LabelProvider()); tv.setContentProvider(ArrayContentProvider.getInstance()); Composite buttonBar = new Composite(main, SWT.NONE); GridDataFactory.fillDefaults().span(2, 1).applyTo(buttonBar); buttonBar.setLayout(new RowLayout()); Button add = new Button(buttonBar, SWT.PUSH); add.setText(UIText.ConfigureUriPage_Add_button); add.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SelectUriWizard selectWizard = new SelectUriWizard(false); WizardDialog dlg = new WizardDialog(getShell(), selectWizard); dlg.setHelpAvailable(false); if (dlg.open() == Window.OK) { URIish uri = selectWizard.getUri(); if (uri.equals(myUri) || myUris.contains(uri)) { String message = NLS.bind(UIText.ConfigureUriPage_DuplicateUriMessage, uri.toPrivateString()); MessageDialog.openInformation(getShell(), UIText.ConfigureUriPage_DuplicateUriTitle, message); return; } credentials = selectWizard.getCredentials(); myUris.add(uri); tv.setInput(myUris); checkPage(); } } }); final Button remove = new Button(buttonBar, SWT.PUSH); remove.setText(UIText.ConfigureUriPage_Remove_button); remove.setEnabled(false); remove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { for (Object o : ((IStructuredSelection) tv.getSelection()).toArray()) myUris.remove(o); tv.setInput(myUris); checkPage(); } }); tv.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { remove.setEnabled(!tv.getSelection().isEmpty()); } }); // to enable keyboard-only operation, let's set the selection upon // traverse tv.getControl().addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (tv.getTable().getSelection().length == 0) { if (tv.getTable().getItemCount() > 0) { tv.setSelection(new StructuredSelection(tv.getTable().getItem(0))); } } } }); if (myConfig != null) { if (!myConfig.getURIs().isEmpty()) { myUri = myConfig.getURIs().get(0); uriText.setText(myUri.toPrivateString()); } for (URIish uri : myConfig.getPushURIs()) myUris.add(uri); tv.setInput(myUris); checkPage(); } else { setPageComplete(false); } } Dialog.applyDialogFont(main); setControl(main); }
From source file:org.nbgit.ui.wizards.ClonePathsWizardPanel.java
License:Open Source License
public void readSettings(Object settings) { assert (settings instanceof WizardDescriptor); defaultUrl = (URIish) ((WizardDescriptor) settings).getProperty("repository"); // NOI18N URIish repository = defaultUrl; boolean repoistoryChanged = !repository.equals(repositoryOrig); repositoryOrig = repository;/* www. ja v a 2s . c o m*/ defaultUrlString = null; boolean resetPullPath = repoistoryChanged || (pullUrl == null); boolean resetPushPath = repoistoryChanged || (pushUrl == null); setDefaultValues(resetPullPath, resetPushPath); }