List of usage examples for org.eclipse.jgit.internal.storage.file FileRepository resolve
@Nullable public ObjectId resolve(String revstr) throws AmbiguousObjectException, IncorrectObjectTypeException, RevisionSyntaxException, IOException
From source file:org.eclipse.egit.ui.submodule.SubmoduleUpdateTest.java
License:Open Source License
@Test public void updateSubmodule() throws Exception { deleteAllProjects();//from w w w.j a v a 2s .c o m assertProjectExistence(PROJ1, false); clearView(); Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile); shareProjects(repositoryFile); assertProjectExistence(PROJ1, true); refreshAndWait(); assertHasRepo(repositoryFile); FileRepository repo = lookupRepository(repositoryFile); ObjectId repoHead = repo.resolve(Constants.HEAD); SubmoduleAddCommand command = new SubmoduleAddCommand(repo); String path = "sub"; command.setPath(path); String uri = new URIish(repo.getDirectory().toURI().toString()).toString(); command.setURI(uri); Repository subRepo = command.call(); assertNotNull(subRepo); Ref head = subRepo.getRef(Constants.HEAD); assertNotNull(head); assertTrue(head.isSymbolic()); assertEquals(Constants.R_HEADS + Constants.MASTER, head.getLeaf().getName()); assertEquals(repoHead, head.getObjectId()); refreshAndWait(); SWTBotTree tree = getOrOpenView().bot().tree(); tree.getAllItems()[0].expand().expandNode(UIText.RepositoriesViewLabelProvider_SubmodulesNodeText).select(); ContextMenuHelper.clickContextMenuSync(tree, myUtil.getPluginLocalizedValue(UPDATE_SUBMODULE_CONTEXT_MENU_LABEL)); TestUtil.joinJobs(JobFamilies.SUBMODULE_UPDATE); refreshAndWait(); head = subRepo.getRef(Constants.HEAD); assertNotNull(head); assertFalse(head.isSymbolic()); assertEquals(repoHead, head.getObjectId()); }
From source file:org.eclipse.egit.ui.view.synchronize.SynchronizeViewPushTest.java
License:Open Source License
@Test public void shouldUpdateTrackingBranchOnPush() throws Exception { makeChangesAndCommit(PROJ1);//ww w.j a va2 s . c o m FileRepository repository = lookupRepository(repositoryFile); ObjectId headId = repository.resolve(Constants.HEAD); String trackingBranch = Constants.R_REMOTES + "origin/master"; launchSynchronization(Constants.HEAD, trackingBranch, false); SWTBotView viewBot = bot.viewByTitle("Synchronize"); SWTBotToolbarButton pushButton = viewBot.toolbarButton(UIText.GitActionContributor_Push); JobJoiner jobJoiner = JobJoiner.startListening(JobFamilies.PUSH, 30, TimeUnit.SECONDS); pushButton.click(); jobJoiner.join(); String destinationString = repositoryFile.getParentFile().getName() + " - " + "origin"; SWTBotShell resultDialog = bot.shell(NLS.bind(UIText.ResultDialog_title, destinationString)); resultDialog.close(); FileRepository remoteRepository = lookupRepository(childRepositoryFile); ObjectId masterOnRemote = remoteRepository.resolve("master"); assertThat("Expected push to update branch on remote repository", masterOnRemote, is(headId)); ObjectId trackingId = repository.resolve(trackingBranch); assertThat("Expected tracking branch to be updated", trackingId, is(headId)); }