Search in sources :

Example 61 with RemoteConfig

use of org.eclipse.jgit.transport.RemoteConfig in project jbosstools-openshift by jbosstools.

the class EGitUtils method getAllRemoteURIs.

/**
 * Returns all uris of alls remotes for the given project.
 *
 * @param project
 *            the project to get all remotes and all uris from
 * @return all uris
 * @throws CoreException
 */
public static List<URIish> getAllRemoteURIs(IProject project) throws CoreException {
    List<RemoteConfig> remoteConfigs = getAllRemoteConfigs(getRepository(project));
    List<URIish> uris = new ArrayList<>();
    if (remoteConfigs != null) {
        for (RemoteConfig remoteConfig : remoteConfigs) {
            uris.addAll(remoteConfig.getURIs());
        }
    }
    return uris;
}
Also used : URIish(org.eclipse.jgit.transport.URIish) ArrayList(java.util.ArrayList) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig)

Example 62 with RemoteConfig

use of org.eclipse.jgit.transport.RemoteConfig in project jbosstools-openshift by jbosstools.

the class EGitUtils method getRemoteConfig.

/**
 * Gets the remote config with the given name from the list of remote
 * configs. Returns <code>null</code> if it was not found.
 *
 * @param remoteName
 *            the remote name
 * @param remoteRepositories
 *            the remote repositories
 * @return the remote config
 *
 * @see #getAllRemoteConfigs(Repository)
 */
public static RemoteConfig getRemoteConfig(String name, List<RemoteConfig> remoteConfigs) {
    Assert.isLegal(name != null);
    RemoteConfig remoteConfig = null;
    for (RemoteConfig config : remoteConfigs) {
        if (name != null && config.getName().equals(name)) {
            remoteConfig = config;
            break;
        }
    }
    return remoteConfig;
}
Also used : RemoteConfig(org.eclipse.jgit.transport.RemoteConfig)

Example 63 with RemoteConfig

use of org.eclipse.jgit.transport.RemoteConfig in project jbosstools-openshift by jbosstools.

the class EGitUtils method getRemoteGitReposFilteredStream.

private static Stream<String> getRemoteGitReposFilteredStream(IProject project) throws CoreException {
    if (project == null) {
        return null;
    }
    Repository repo = getRepository(project);
    if (repo == null) {
        return null;
    }
    // Returned configurations are ordered lexicographically by names.
    List<RemoteConfig> remoteConfigs = getAllRemoteConfigs(repo);
    Collections.sort(remoteConfigs, new Comparator<RemoteConfig>() {

        @Override
        public int compare(RemoteConfig o1, RemoteConfig o2) {
            if (ORIGIN.equals(o1.getName())) {
                return -1;
            }
            if (ORIGIN.equals(o2.getName())) {
                return 1;
            }
            return o1.getName().compareToIgnoreCase(o2.getName());
        }
    });
    return remoteConfigs.stream().map(rc -> getFetchURI(rc)).filter(uri -> uri != null && uri.toString().startsWith("http")).map(URIish::toString);
}
Also used : Arrays(java.util.Arrays) IndexDiff(org.eclipse.jgit.lib.IndexDiff) URISyntaxException(java.net.URISyntaxException) MissingObjectException(org.eclipse.jgit.errors.MissingObjectException) CoreException(org.eclipse.core.runtime.CoreException) IteratorService(org.eclipse.egit.core.IteratorService) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig) RevWalk(org.eclipse.jgit.revwalk.RevWalk) PostCloneTask(org.eclipse.egit.core.op.CloneOperation.PostCloneTask) Config(org.eclipse.jgit.lib.Config) IStatus(org.eclipse.core.runtime.IStatus) Matcher(java.util.regex.Matcher) URIish(org.eclipse.jgit.transport.URIish) ConnectProviderOperation(org.eclipse.egit.core.op.ConnectProviderOperation) FetchResult(org.eclipse.jgit.transport.FetchResult) FileRepositoryBuilder(org.eclipse.jgit.storage.file.FileRepositoryBuilder) EclipseGitProgressTransformer(org.eclipse.egit.core.EclipseGitProgressTransformer) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) NLS(org.eclipse.osgi.util.NLS) RefSpec(org.eclipse.jgit.transport.RefSpec) Collection(java.util.Collection) Assert(org.eclipse.core.runtime.Assert) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) Constants(org.eclipse.jgit.lib.Constants) RevWalkUtils(org.eclipse.jgit.revwalk.RevWalkUtils) RepositoryProvider(org.eclipse.team.core.RepositoryProvider) Collectors(java.util.stream.Collectors) MergeStrategy(org.eclipse.jgit.merge.MergeStrategy) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) Stream(java.util.stream.Stream) NoWorkTreeException(org.eclipse.jgit.errors.NoWorkTreeException) AddToIndexOperation(org.eclipse.egit.core.op.AddToIndexOperation) Ref(org.eclipse.jgit.lib.Ref) PushResult(org.eclipse.jgit.transport.PushResult) FetchOperation(org.eclipse.egit.core.op.FetchOperation) Pattern(java.util.regex.Pattern) NotSupportedException(org.eclipse.jgit.errors.NotSupportedException) BranchTrackingStatus(org.eclipse.jgit.lib.BranchTrackingStatus) RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) CheckoutResult(org.eclipse.jgit.api.CheckoutResult) RevCommit(org.eclipse.jgit.revwalk.RevCommit) CloneOperation(org.eclipse.egit.core.op.CloneOperation) IncorrectObjectTypeException(org.eclipse.jgit.errors.IncorrectObjectTypeException) Transport(org.eclipse.jgit.transport.Transport) StringUtils(org.eclipse.jgit.util.StringUtils) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) CommitOperation(org.eclipse.egit.core.op.CommitOperation) HashSet(java.util.HashSet) IProject(org.eclipse.core.resources.IProject) UserConfig(org.eclipse.jgit.lib.UserConfig) PushOperationSpecification(org.eclipse.egit.core.op.PushOperationSpecification) MergeOperation(org.eclipse.egit.core.op.MergeOperation) PushOperationResult(org.eclipse.egit.core.op.PushOperationResult) RegexUtils(org.jboss.tools.openshift.internal.egit.core.utils.RegexUtils) OutputStream(java.io.OutputStream) RevFilter(org.eclipse.jgit.revwalk.filter.RevFilter) MalformedURLException(java.net.MalformedURLException) CreateLocalBranchOperation(org.eclipse.egit.core.op.CreateLocalBranchOperation) InitCommand(org.eclipse.jgit.api.InitCommand) ConfigConstants(org.eclipse.jgit.lib.ConfigConstants) IOException(java.io.IOException) File(java.io.File) ObjectId(org.eclipse.jgit.lib.ObjectId) JGitInternalException(org.eclipse.jgit.api.errors.JGitInternalException) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) EGitCoreActivator(org.jboss.tools.openshift.internal.egit.core.EGitCoreActivator) IResource(org.eclipse.core.resources.IResource) Platform(org.eclipse.core.runtime.Platform) MergeResult(org.eclipse.jgit.api.MergeResult) StoredConfig(org.eclipse.jgit.lib.StoredConfig) PushOperation(org.eclipse.egit.core.op.PushOperation) Git(org.eclipse.jgit.api.Git) Comparator(java.util.Comparator) BranchOperation(org.eclipse.egit.core.op.BranchOperation) Collections(java.util.Collections) Repository(org.eclipse.jgit.lib.Repository) URIish(org.eclipse.jgit.transport.URIish) Repository(org.eclipse.jgit.lib.Repository) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig)

Aggregations

RemoteConfig (org.eclipse.jgit.transport.RemoteConfig)63 URISyntaxException (java.net.URISyntaxException)23 StoredConfig (org.eclipse.jgit.lib.StoredConfig)21 URIish (org.eclipse.jgit.transport.URIish)21 IOException (java.io.IOException)16 RefSpec (org.eclipse.jgit.transport.RefSpec)14 Repository (org.eclipse.jgit.lib.Repository)13 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)7 Button (org.eclipse.swt.widgets.Button)6 Composite (org.eclipse.swt.widgets.Composite)6 File (java.io.File)5 Git (org.eclipse.jgit.api.Git)5 Ref (org.eclipse.jgit.lib.Ref)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 Label (org.eclipse.swt.widgets.Label)5 List (java.util.List)4 CoreException (org.eclipse.core.runtime.CoreException)4 UIText (org.eclipse.egit.ui.internal.UIText)4