Search in sources :

Example 26 with GitSynchronizeDataSet

use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet in project egit by eclipse.

the class PushAction method runPushOperation.

private void runPushOperation() {
    GitSynchronizeDataSet gsds = (GitSynchronizeDataSet) getConfiguration().getProperty(SYNCHRONIZATION_DATA);
    for (GitSynchronizeData gsd : gsds) {
        String remoteName = gsd.getDstRemoteName();
        if (remoteName == null)
            continue;
        RemoteConfig rc;
        Repository repo = gsd.getRepository();
        StoredConfig config = repo.getConfig();
        try {
            rc = new RemoteConfig(config, remoteName);
        } catch (URISyntaxException e) {
            Activator.logError("Unable to create RemoteConfiguration for remote: " + remoteName, // $NON-NLS-1$
            e);
            continue;
        }
        if (rc.getPushRefSpecs().isEmpty())
            // $NON-NLS-1$
            rc.addPushRefSpec(new RefSpec(HEAD + ":" + gsd.getDstMerge()));
        PushOperationUI push = new PushOperationUI(repo, rc, false);
        push.setCredentialsProvider(new EGitCredentialsProvider());
        push.start();
    }
}
Also used : StoredConfig(org.eclipse.jgit.lib.StoredConfig) GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) Repository(org.eclipse.jgit.lib.Repository) RefSpec(org.eclipse.jgit.transport.RefSpec) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) URISyntaxException(java.net.URISyntaxException) PushOperationUI(org.eclipse.egit.ui.internal.push.PushOperationUI) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig) EGitCredentialsProvider(org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider)

Example 27 with GitSynchronizeDataSet

use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet in project egit by eclipse.

the class GitContainerMapping method getTraversals.

@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
    GitModelObject[] children = ((GitModelObjectContainer) getModelObject()).getChildren();
    Set<ResourceTraversal> result = new LinkedHashSet<>();
    final GitSynchronizeDataSet dataSet;
    if (context instanceof GitSubscriberResourceMappingContext)
        dataSet = ((GitSubscriberResourceMappingContext) context).getSyncData();
    else
        dataSet = null;
    for (GitModelObject child : children) {
        if (child.isContainer())
            result.addAll(createTraversalForContainer(child, dataSet));
        else
            result.add(createTraversalForFile(child, dataSet));
    }
    return result.toArray(new ResourceTraversal[result.size()]);
}
Also used : ResourceTraversal(org.eclipse.core.resources.mapping.ResourceTraversal) LinkedHashSet(java.util.LinkedHashSet) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) GitSubscriberResourceMappingContext(org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext) GitModelObjectContainer(org.eclipse.egit.ui.internal.synchronize.model.GitModelObjectContainer) GitModelObject(org.eclipse.egit.ui.internal.synchronize.model.GitModelObject)

Example 28 with GitSynchronizeDataSet

use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet in project egit by eclipse.

the class GitScopeUtil method createScopeManager.

/**
 * Creates a new {@link SubscriberScopeManager} for the given set of
 * {@link IResource}s
 *
 * @param resources
 * @param monitor
 * @return {@link SubscriberScopeManager}
 */
private static SubscriberScopeManager createScopeManager(final IResource[] resources, IProgressMonitor monitor) {
    ResourceMapping[] mappings = GitScopeUtil.getResourceMappings(resources);
    GitSynchronizeDataSet set = new GitSynchronizeDataSet();
    final GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(set);
    monitor.setTaskName(UIText.GitModelSynchronize_fetchGitDataJobName);
    subscriber.init(monitor);
    SubscriberScopeManager manager = new SubscriberScopeManager(UIText.GitScopeOperation_GitScopeManager, mappings, subscriber, true);
    return manager;
}
Also used : GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) SubscriberScopeManager(org.eclipse.team.core.subscribers.SubscriberScopeManager) ResourceMapping(org.eclipse.core.resources.mapping.ResourceMapping) GitResourceVariantTreeSubscriber(org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)

Example 29 with GitSynchronizeDataSet

use of org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet in project egit by eclipse.

the class SynchronizeWorkspaceActionHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IResource[] resources = getSelectedResources(event);
    Map<Repository, Set<IResource>> containerMap = mapContainerResources(resources);
    if (containerMap.isEmpty())
        return null;
    boolean launchFetch = Activator.getDefault().getPreferenceStore().getBoolean(UIPreferences.SYNC_VIEW_FETCH_BEFORE_LAUNCH);
    GitSynchronizeDataSet gsdSet = new GitSynchronizeDataSet();
    for (Entry<Repository, Set<IResource>> entry : containerMap.entrySet()) try {
        Repository repo = entry.getKey();
        String dstRef = getDstRef(repo, launchFetch);
        GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, dstRef, true);
        Set<IResource> containers = entry.getValue();
        if (!containers.isEmpty())
            data.setIncludedResources(containers);
        gsdSet.add(data);
    } catch (IOException e) {
        Activator.handleError(e.getMessage(), e, true);
    }
    GitModelSynchronize.launch(gsdSet, getSelectedResources(event));
    return null;
}
Also used : GitSynchronizeData(org.eclipse.egit.core.synchronize.dto.GitSynchronizeData) Repository(org.eclipse.jgit.lib.Repository) HashSet(java.util.HashSet) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) Set(java.util.Set) GitSynchronizeDataSet(org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet) IOException(java.io.IOException) IResource(org.eclipse.core.resources.IResource)

Aggregations

GitSynchronizeDataSet (org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet)29 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)26 Test (org.junit.Test)15 IFile (org.eclipse.core.resources.IFile)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 IResourceVariant (org.eclipse.team.core.variants.IResourceVariant)8 IResource (org.eclipse.core.resources.IResource)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 HashSet (java.util.HashSet)6 IStorage (org.eclipse.core.resources.IStorage)6 ResourceMapping (org.eclipse.core.resources.mapping.ResourceMapping)6 IOException (java.io.IOException)4 GitResourceVariantTreeSubscriber (org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)4 GitSubscriberResourceMappingContext (org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext)4 Git (org.eclipse.jgit.api.Git)4 Repository (org.eclipse.jgit.lib.Repository)4 File (java.io.File)3 SubscriberScopeManager (org.eclipse.team.core.subscribers.SubscriberScopeManager)3 LinkedHashSet (java.util.LinkedHashSet)2