List of usage examples for org.eclipse.jgit.lib Constants MASTER
String MASTER
To view the source code for org.eclipse.jgit.lib Constants MASTER.
Click Source Link
From source file:org.eclipse.egit.core.op.ConfigureGerritAfterCloneTask.java
License:Open Source License
private void configureGerrit(Repository repository) throws URISyntaxException, IOException { StoredConfig config = repository.getConfig(); RemoteConfig remoteConfig;//w w w . j a va 2 s . co m remoteConfig = GerritUtil.findRemoteConfig(config, remoteName); if (remoteConfig == null) { return; } GerritUtil.configurePushURI(remoteConfig, new URIish(uri)); GerritUtil.configurePushRefSpec(remoteConfig, Constants.MASTER); GerritUtil.configureFetchNotes(remoteConfig); GerritUtil.setCreateChangeId(config); remoteConfig.update(config); config.save(); }
From source file:org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriberTest.java
License:Open Source License
/** * This test simulates that user work and made some changes on branch 'test' * and then try to synchronize "test" and 'master' branch. * * @throws Exception//from www. j a va2 s .c o m */ @Test public void shouldReturnSrcBranchAsBase() throws Exception { // when String fileName = "Main.java"; File file = testRepo.createFile(iProject, fileName); RevCommit commit = testRepo.appendContentAndCommit(iProject, file, "class Main {}", "initial commit"); IFile mainJava = testRepo.getIFile(iProject, file); testRepo.createAndCheckoutBranch(Constants.HEAD, Constants.R_HEADS + "test"); testRepo.appendContentAndCommit(iProject, file, "// test1", "secont commit"); // given GitResourceVariantTreeSubscriber grvts = createGitResourceVariantTreeSubscriber(Constants.HEAD, Constants.R_HEADS + Constants.MASTER); grvts.getBaseTree(); IResourceVariantTree baseTree = grvts.getBaseTree(); // then IResourceVariant actual = commonAssertionsForBaseTree(baseTree, mainJava); assertEquals(commit.abbreviate(7).name() + "...", actual.getContentIdentifier()); }
From source file:org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriberTest.java
License:Open Source License
/** * Both source and destination branches has some different commits but they * has also common ancestor. This situation is described more detailed in * bug #317934/*from www . ja va 2 s .c om*/ * * This test passes when it is run as a stand alone test case, but it fails * when it is run as part of test suite. It throws NPE when it try's to * checkout master branch. * * @throws Exception */ @Test @Ignore public void shouldReturnCommonAncestorAsBase() throws Exception { // when String fileName = "Main.java"; File file = testRepo.createFile(iProject, fileName); RevCommit commit = testRepo.appendContentAndCommit(iProject, file, "class Main {}", "initial commit"); IFile mainJava = testRepo.getIFile(iProject, file); // this should be our common ancestor ObjectId fileId = findFileId(commit, mainJava); testRepo.createAndCheckoutBranch(Constants.HEAD, Constants.R_HEADS + "test"); testRepo.appendContentAndCommit(iProject, file, "// test 1", "second commit"); testRepo.checkoutBranch(Constants.R_HEADS + Constants.MASTER); testRepo.appendContentAndCommit(iProject, file, "// test 2", "third commit"); // given GitResourceVariantTreeSubscriber grvts = createGitResourceVariantTreeSubscriber(Constants.HEAD, Constants.R_HEADS + "test"); grvts.getBaseTree(); IResourceVariantTree baseTree = grvts.getBaseTree(); // then IResourceVariant actual = commonAssertionsForBaseTree(baseTree, mainJava); assertEquals(fileId.getName(), actual.getContentIdentifier()); }
From source file:org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriberTest2.java
License:Open Source License
/** * Both source and destination branches has some different commits but they * has also common ancestor. This situation is described more detailed in * bug #317934/*from w w w .j av a 2s. co m*/ * * This test passes when it is run as a stand alone test case, but it fails * when it is run as part of test suite. It throws NPE when it try's to * checkout master branch. * * @throws Exception */ @Test public void shouldReturnCommonAncestorAsBase() throws Exception { // when String fileName = "Main.java"; File file = testRepo.createFile(iProject, fileName); RevCommit commit = testRepo.appendContentAndCommit(iProject, file, "class Main {}", "initial commit"); IFile mainJava = testRepo.getIFile(iProject, file); // this should be our common ancestor testRepo.createAndCheckoutBranch(Constants.HEAD, Constants.R_HEADS + "test"); testRepo.appendContentAndCommit(iProject, file, "// test 1", "second commit"); testRepo.checkoutBranch(Constants.R_HEADS + Constants.MASTER); testRepo.appendContentAndCommit(iProject, file, "// test 2", "third commit"); // given GitResourceVariantTreeSubscriber grvts = createGitResourceVariantTreeSubscriber(Constants.HEAD, Constants.R_HEADS + "test"); grvts.getBaseTree(); IResourceVariantTree baseTree = grvts.getBaseTree(); // then IResourceVariant actual = commonAssertionsForBaseTree(baseTree, mainJava); assertEquals(commit.abbreviate(7).name() + "...", actual.getContentIdentifier()); }
From source file:org.eclipse.egit.core.synchronize.GitResourceVariantTreeTest.java
License:Open Source License
/** * Create and commit Main.java file in master branch, then create branch * "test" checkout nearly created branch and modify Main.java file. * getResourceVariant() should obtain Main.java file content from "master" * branch. Passes only when it is run as a single test, not as a part of * largest test suite// w w w . j a v a 2 s .c o m * * @throws Exception */ @Test public void shouldReturnDifferentResourceVariant() throws Exception { // when String fileName = "Main.java"; File file = testRepo.createFile(iProject, fileName); testRepo.appendContentAndCommit(iProject, file, "class Main {}", "initial commit"); IFile mainJava = testRepo.getIFile(iProject, file); testRepo.createAndCheckoutBranch(Constants.R_HEADS + Constants.MASTER, Constants.R_HEADS + "test"); testRepo.appendContentAndCommit(iProject, file, "// test", "first commit"); GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, MASTER, false); GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data); // given GitResourceVariantTree grvt = new GitRemoteResourceVariantTree(dataSet); // then IResourceVariant actual = grvt.getResourceVariant(mainJava); assertNotNull(actual); assertEquals(fileName, actual.getName()); InputStream actualIn = actual.getStorage(new NullProgressMonitor()).getContents(); byte[] actualByte = getBytesAndCloseStream(actualIn); InputStream expectedIn = mainJava.getContents(); byte[] expectedByte = getBytesAndCloseStream(expectedIn); // assert arrays not equals if (Arrays.equals(expectedByte, actualByte)) fail(); else assertTrue(true); }
From source file:org.eclipse.egit.core.test.GitURITest.java
License:Open Source License
@Test public void testScmUriWithPath() throws Exception { ScmUrlImportDescription description = new ScmUrlImportDescription( "scm:git:git://git.eclipse.org/gitroot/platform/eclipse.platform.team.git;path=\"bundles/org.eclipse.team.core\"", null);/* www .j a v a2s .c o m*/ URI uri = description.getUri(); GitURI gitUri = new GitURI(uri); assertEquals("bundles/org.eclipse.team.core", gitUri.getPath().toString()); URIish uriish = new URIish("git://git.eclipse.org/gitroot/platform/eclipse.platform.team.git"); assertEquals(uriish, gitUri.getRepository()); assertEquals(Constants.MASTER, gitUri.getTag()); String refString = capability.asReference(uri, "org.eclipse.team.core"); assertEquals( "1.0,git://git.eclipse.org/gitroot/platform/eclipse.platform.team.git,master,bundles/org.eclipse.team.core", refString); }
From source file:org.eclipse.egit.internal.mylyn.ui.tasks.TaskActivationListener.java
License:Open Source License
public void preTaskActivated(ITask task) { // TODO if there's a context, should we browse it to deduce which repo to choose? String branch = task.getTaskKey() != null ? task.getTaskKey() : task.getTaskId(); String branchFullName = Constants.R_HEADS + branch; RepositoryAndBranchSelectionDialog dialog = new RepositoryAndBranchSelectionDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), branchFullName); if (dialog.open() == Window.OK) { try {/* w ww. j av a 2 s.c o m*/ List<Repository> repos = dialog.getSelectedRepositories(); for (Repository repo : repos) { // Create new branch, if branch with proposed name doesn't exist, otherwise checkout if (repo.getRefDatabase().getRef(branch) == null) { CreateLocalBranchOperation createOperation = new CreateLocalBranchOperation(repo, branch, repo.getRef(Constants.R_HEADS + Constants.MASTER)); createOperation.execute(null); } BranchOperation operation = new BranchOperation(repo, dialog.getBranch()); operation.execute(null); } } catch (CoreException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:org.eclipse.egit.internal.mylyn.ui.tasks.TaskActivationListener.java
License:Open Source License
public void taskDeactivated(ITask task) { // FIXME hack, we should detect which repository to switch to master // we should base this off the task context imho... we should be able to guess based on the projects in the context // if we get a conflict... this may be a bit more complicated... but how common would this be? ContextCorePlugin.getContextManager(); Repository repository = Activator.getDefault().getRepositoryCache().getAllRepositories()[0]; try {// w w w . j ava2s . co m BranchOperation operation = new BranchOperation(repository, Constants.R_HEADS + Constants.MASTER); operation.execute(null); } catch (CoreException e) { e.printStackTrace(); } }
From source file:org.eclipse.egit.ui.internal.branch.BranchProjectTrackerTest.java
License:Open Source License
@Before public void setup() throws Exception { closeWelcomePage();/* w ww . j a v a 2 s . co m*/ File repoFile = createProjectAndCommitToRepository(); assertNotNull(repoFile); repository = Activator.getDefault().getRepositoryCache().lookupRepository(repoFile); assertNotNull(repository); BranchProjectTracker tracker = new BranchProjectTracker(repository); org.eclipse.egit.ui.Activator.getDefault().getPreferenceStore() .setValue(tracker.getPreference(Constants.MASTER), ""); org.eclipse.egit.ui.Activator.getDefault().getPreferenceStore().setValue(tracker.getPreference(BRANCH), ""); }
From source file:org.eclipse.egit.ui.internal.branch.BranchProjectTrackerTest.java
License:Open Source License
@Test public void twoProjectsWithOnlyOneOnBranch() throws Exception { BranchProjectTracker tracker = new BranchProjectTracker(repository); String[] paths = tracker.getProjectPaths(); assertNotNull(paths);/*from w w w .ja va2 s.co m*/ assertEquals(0, paths.length); assertNotNull(Git.wrap(repository).branchCreate().setName(BRANCH).call()); BranchOperationUI.checkout(repository, BRANCH).start(); TestUtil.joinJobs(JobFamilies.CHECKOUT); paths = tracker.getProjectPaths(Constants.MASTER); assertNotNull(paths); assertEquals(2, paths.length); IProject project1 = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1); IProject project2 = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ2); assertTrue(project1.exists()); assertTrue(project2.exists()); project1.delete(true, true, new NullProgressMonitor()); assertNotNull(Git.wrap(repository).commit().setAll(true).setMessage("deleting project").call()); assertFalse(project1.exists()); BranchOperationUI.checkout(repository, Constants.MASTER).start(); TestUtil.joinJobs(JobFamilies.CHECKOUT); paths = tracker.getProjectPaths(BRANCH); assertNotNull(paths); assertEquals(1, paths.length); assertTrue(project1.exists()); assertTrue(project2.exists()); BranchOperationUI.checkout(repository, BRANCH).start(); TestUtil.joinJobs(JobFamilies.CHECKOUT); assertTrue(project1.exists()); assertFalse(project1.isOpen()); assertTrue(project2.exists()); assertTrue(project2.isOpen()); BranchOperationUI.checkout(repository, Constants.MASTER).start(); TestUtil.joinJobs(JobFamilies.CHECKOUT); assertTrue(project1.exists()); assertTrue(project1.isOpen()); assertTrue(project2.exists()); assertTrue(project2.isOpen()); }