List of usage examples for org.eclipse.jgit.api Git Git
public Git(Repository repo)
From source file:org.eclipse.egit.core.synchronize.GitResourceVariantTreeTest.java
License:Open Source License
/** * getResourceVariant() should return null when given resource doesn't exist * in repository.// w w w. j a va2 s . c o m * * @throws Exception */ @Test public void shouldReturnNullResourceVariant2() throws Exception { // when IPackageFragment iPackage = project.createPackage("org.egit.test"); IType mainJava = project.createType(iPackage, "Main.java", "class Main {}"); new Git(repo).commit().setAuthor("JUnit", "junit@egit.org").setMessage("Initial commit").call(); GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER, false); GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data); // given GitResourceVariantTree grvt = new GitRemoteResourceVariantTree(dataSet); // then assertNull(grvt.getResourceVariant(mainJava.getResource())); }
From source file:org.eclipse.egit.core.synchronize.GitSubscriberMergeContextTest.java
License:Open Source License
@Before public void setUp() throws Exception { super.setUp(); iProject = project.project;/*from w w w. j a v a 2 s . co m*/ testRepo = new TestRepository(gitDir); testRepo.connect(iProject); repo = RepositoryMapping.getMapping(iProject).getRepository(); // make initial commit new Git(repo).commit().setAuthor("JUnit", "junit@jgit.org").setMessage("Initial commit").call(); }
From source file:org.eclipse.egit.core.synchronize.GitSubscriberMergeContextTest.java
License:Open Source License
@Test public void markAsMerged() throws Exception { GitSynchronizeData gsd = new GitSynchronizeData(repo, HEAD, HEAD, false); GitSynchronizeDataSet gsds = new GitSynchronizeDataSet(gsd); GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds); String fileName = "src/Main.java"; File file = testRepo.createFile(iProject, fileName); testRepo.appendContentAndCommit(iProject, file, "class Main {}", "some file"); testRepo.addToIndex(iProject.getFile(".classpath")); testRepo.addToIndex(iProject.getFile(".project")); testRepo.commit("project files"); IFile workspaceFile = testRepo.getIFile(iProject, file); ResourceMapping mapping = AdapterUtils.adapt(workspaceFile, ResourceMapping.class); ResourceMapping[] inputMappings = new ResourceMapping[] { mapping }; SubscriberScopeManager manager = new SubscriberScopeManager("Scope", inputMappings, subscriber, true); testRepo.appendFileContent(file, "some changes"); Status status = new Git(repo).status().call(); assertEquals(0, status.getAdded().size()); assertEquals(1, status.getModified().size()); String repoRelativePath = testRepo.getRepoRelativePath(workspaceFile.getLocation().toPortableString()); assertTrue(status.getModified().contains(repoRelativePath)); GitSubscriberMergeContext mergeContext = new GitSubscriberMergeContext(subscriber, manager, gsds); IDiff node = new ResourceDiff(iProject.getFolder("src"), IDiff.CHANGE); mergeContext.markAsMerged(node, true, null); status = new Git(repo).status().call(); assertEquals(1, status.getChanged().size()); assertEquals(0, status.getModified().size()); assertTrue(status.getChanged().contains(repoRelativePath)); }
From source file:org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContextTest.java
License:Open Source License
@Override @Before//from www. ja v a 2 s . c om public void setUp() throws Exception { super.setUp(); iProject = project.project; testRepo = new TestRepository(gitDir); testRepo.connect(iProject); repo = RepositoryMapping.getMapping(iProject).getRepository(); // make initial commit new Git(repo).commit().setAuthor("JUnit", "junit@jgit.org").setMessage("Initial commit").call(); }
From source file:org.eclipse.egit.core.synchronize.GitSyncInfoTest.java
License:Open Source License
private RevCommit commit() throws Exception { Git git = new Git(repo); CommitCommand commit = git.commit(); commit.setMessage("Initial commit"); commit.setAuthor("EGit", "egi@eclipse.org"); return commit.call(); }
From source file:org.eclipse.egit.core.synchronize.StagedChangeCacheTest.java
License:Open Source License
@Test public void shouldListSingleWorkspaceAddition() throws Exception { // given/*from w w w. j a v a 2 s .co m*/ writeTrashFile(db, "a.txt", "trash"); new Git(db).add().addFilepattern("a.txt").call(); // when Map<String, Change> result = StagedChangeCache.build(db); // then assertThat(result.size(), is(1)); assertFileAddition(result, "a.txt", "a.txt"); }
From source file:org.eclipse.egit.core.synchronize.StagedChangeCacheTest.java
License:Open Source License
@Test public void shouldListTwoWorkspaceAdditions() throws Exception { // given/*from w w w . j a v a 2 s . c o m*/ writeTrashFile(db, "a.txt", "trash"); writeTrashFile(db, "b.txt", "trash"); new Git(db).add().addFilepattern("a.txt").addFilepattern("b.txt").call(); // when Map<String, Change> result = StagedChangeCache.build(db); // then assertThat(result.size(), is(2)); assertFileAddition(result, "a.txt", "a.txt"); assertFileAddition(result, "b.txt", "b.txt"); }
From source file:org.eclipse.egit.core.synchronize.StagedChangeCacheTest.java
License:Open Source License
@Test public void shouldListSingleWorkspaceAdditionInFolder() throws Exception { // given//from w w w .ja v a 2s . c o m writeTrashFile(db, "folder/a.txt", "trash"); new Git(db).add().addFilepattern("folder/a.txt").call(); // when Map<String, Change> result = StagedChangeCache.build(db); // then assertThat(result.size(), is(1)); assertFileAddition(result, "folder/a.txt", "a.txt"); }
From source file:org.eclipse.egit.core.synchronize.StagedChangeCacheTest.java
License:Open Source License
@Test public void shouldListTwoWorkspaceAdditionsInFolder() throws Exception { // given/* w ww. j a va 2 s. com*/ writeTrashFile(db, "folder/a.txt", "trash"); writeTrashFile(db, "folder/b.txt", "trash"); new Git(db).add().addFilepattern("folder/a.txt").addFilepattern("folder/b.txt").call(); // when Map<String, Change> result = StagedChangeCache.build(db); // then assertThat(result.size(), is(2)); assertFileAddition(result, "folder/a.txt", "a.txt"); assertFileAddition(result, "folder/b.txt", "b.txt"); }
From source file:org.eclipse.egit.core.synchronize.StagedChangeCacheTest.java
License:Open Source License
@Test public void shouldListSingleWorkspaceDeletion() throws Exception { // given//from www . j ava2s . c o m Git git = new Git(db); writeTrashFile(db, "a.txt", "trash"); git.add().addFilepattern("a.txt").call(); git.commit().setMessage("initial add").call(); git.rm().addFilepattern("a.txt").call(); // when Map<String, Change> result = StagedChangeCache.build(db); // then assertThat(result.size(), is(1)); assertFileDeletion(result, "a.txt", "a.txt"); }