Search in sources :

Example 16 with IFileHistory

use of org.eclipse.team.core.history.IFileHistory in project egit by eclipse.

the class HistoryTest method testDeepHistory_A.

@Test
public void testDeepHistory_A() {
    GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
    assertNotNull(provider);
    IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
    IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/A.txt"), IFileHistoryProvider.NONE, new NullProgressMonitor());
    IFileRevision[] fileRevisions = fileHistory.getFileRevisions();
    assertEquals(1, fileRevisions.length);
    assertEquals("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359", fileRevisions[0].getContentIdentifier());
    assertEquals("J. Author", fileRevisions[0].getAuthor());
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 17 with IFileHistory

use of org.eclipse.team.core.history.IFileHistory in project bndtools by bndtools.

the class ReleaseUtils method getTeamRevisions.

/**
 * Returns the file revisions for the given resource. If the flags contains IFileHistoryProvider.SINGLE_REVISION
 * then only the revision corresponding to the base corresponding to the local resource is fetched. If the flags
 * contains IFileHistoryProvider.SINGLE_LINE_OF_DESCENT the resulting history will be restricted to a single
 * line-of-descent (e.g. a single branch).
 *
 * @param resource
 * @param flags
 * @param monitor
 * @return the file revisions for the given resource
 */
public static IFileRevision[] getTeamRevisions(IResource resource, int flags, IProgressMonitor monitor) {
    RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject());
    if (provider == null) {
        return null;
    }
    IFileHistory history = provider.getFileHistoryProvider().getFileHistoryFor(resource, flags, monitor);
    if (history == null) {
        return new IFileRevision[0];
    }
    return history.getFileRevisions();
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) IFileRevision(org.eclipse.team.core.history.IFileRevision) RepositoryProvider(org.eclipse.team.core.RepositoryProvider)

Aggregations

IFileHistory (org.eclipse.team.core.history.IFileHistory)17 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)16 IFileRevision (org.eclipse.team.core.history.IFileRevision)16 Test (org.junit.Test)15 GitProvider (org.eclipse.egit.core.GitProvider)8 IFileHistoryProvider (org.eclipse.team.core.history.IFileHistoryProvider)8 RevCommit (org.eclipse.jgit.revwalk.RevCommit)5 ArrayList (java.util.ArrayList)3 IFile (org.eclipse.core.resources.IFile)2 IStorage (org.eclipse.core.resources.IStorage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 IProject (org.eclipse.core.resources.IProject)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 GitFileHistoryProvider (org.eclipse.egit.core.internal.storage.GitFileHistoryProvider)1 ConnectProviderOperation (org.eclipse.egit.core.op.ConnectProviderOperation)1 DisconnectProviderOperation (org.eclipse.egit.core.op.DisconnectProviderOperation)1 GitResourceVariantTreeSubscriber (org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber)1 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)1 GitSynchronizeDataSet (org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet)1