List of usage examples for org.eclipse.jgit.lib Constants DOT_GIT
String DOT_GIT
To view the source code for org.eclipse.jgit.lib Constants DOT_GIT.
Click Source Link
From source file:org.eclipse.egit.ui.view.repositories.GitRepositoriesViewBranchHandlingTest.java
License:Open Source License
@BeforeClass public static void beforeClass() throws Exception { repositoryFile = createProjectAndCommitToRepository(); remoteRepositoryFile = createRemoteRepository(repositoryFile); // now let's clone the remote repository final URIish uri = new URIish(remoteRepositoryFile.getPath()); final File workdir = new File(getTestDirectory(), "Cloned"); CloneOperation op = new CloneOperation(uri, true, null, workdir, "refs/heads/master", "origin", 0); op.run(null);// w ww.java 2 s . c o m clonedRepositoryFile = new File(workdir, Constants.DOT_GIT); }
From source file:org.eclipse.egit.ui.view.repositories.GitRepositoriesViewFetchAndPushTest.java
License:Open Source License
@BeforeClass public static void beforeClass() throws Exception { repositoryFile = createProjectAndCommitToRepository(); remoteRepositoryFile = createRemoteRepository(repositoryFile); // now let's clone the remote repository URIish uri = new URIish("file:///" + remoteRepositoryFile.getPath()); File workdir = new File(getTestDirectory(), "ClonedRepo"); CloneOperation op = new CloneOperation(uri, true, null, workdir, "refs/heads/master", "origin", 0); op.run(null);/*from ww w.j ava 2 s . com*/ clonedRepositoryFile = new File(workdir, Constants.DOT_GIT); // now let's clone the remote repository uri = new URIish(remoteRepositoryFile.getPath()); workdir = new File(getTestDirectory(), "ClonedRepo2"); op = new CloneOperation(uri, true, null, workdir, "refs/heads/master", "origin", 0); op.run(null); clonedRepositoryFile2 = new File(workdir, Constants.DOT_GIT); }
From source file:org.eclipse.egit.ui.view.repositories.GitRepositoriesViewRepoHandlingTest.java
License:Open Source License
@Test public void testCreateRepository() throws Exception { clearView();/*from w w w . j a v a2 s. c o m*/ refreshAndWait(); assertEmpty(); // create a non-bare repository getOrOpenView().toolbarButton(myUtil.getPluginLocalizedValue("RepoViewCreateRepository.tooltip")).click(); SWTBotShell shell = bot.shell(UIText.NewRepositoryWizard_WizardTitle).activate(); IPath newPath = new Path(getTestDirectory().getPath()).append("NewRepository"); shell.bot().textWithLabel(UIText.CreateRepositoryPage_DirectoryLabel).setText(newPath.toOSString()); shell.bot().button(IDialogConstants.FINISH_LABEL).click(); refreshAndWait(); File repoFile = new File(newPath.toFile(), Constants.DOT_GIT); myRepoViewUtil.getRootItem(getOrOpenView().bot().tree(), repoFile); assertFalse(myRepoViewUtil.lookupRepository(repoFile).isBare()); // create a bare repository getOrOpenView().toolbarButton(myUtil.getPluginLocalizedValue("RepoViewCreateRepository.tooltip")).click(); shell = bot.shell(UIText.NewRepositoryWizard_WizardTitle).activate(); newPath = new Path(getTestDirectory().getPath()).append("bare").append("NewBareRepository"); shell.bot().textWithLabel(UIText.CreateRepositoryPage_DirectoryLabel).setText(newPath.toOSString()); shell.bot().checkBox(UIText.CreateRepositoryPage_BareCheckbox).select(); shell.bot().button(IDialogConstants.FINISH_LABEL).click(); refreshAndWait(); repoFile = newPath.toFile(); myRepoViewUtil.getRootItem(getOrOpenView().bot().tree(), repoFile); assertTrue(myRepoViewUtil.lookupRepository(repoFile).isBare()); }
From source file:org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTest.java
License:Open Source License
/** * Import wizard golden path test/*from w w w . j a va 2 s.c o m*/ * * @throws Exception */ @Test public void testImportWizard() throws Exception { deleteAllProjects(); assertProjectExistence(PROJ1, false); SWTBotTree tree = getOrOpenView().bot().tree(); SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile); String wizardTitle = NLS.bind( UIText.GitCreateProjectViaWizardWizard_WizardTitle, repositoryFile.getPath()); // start wizard from root item item.select(); ContextMenuHelper.clickContextMenu(tree, myUtil .getPluginLocalizedValue("ImportProjectsCommand")); SWTBotShell shell = bot.shell(wizardTitle); bot.radio(UIText.GitSelectWizardPage_ImportExistingButton).click(); // auto share bot.radio(UIText.GitSelectWizardPage_AutoShareButton).click(); TableCollection selected = shell.bot().tree().selection(); String wizardNode = selected.get(0, 0); // wizard directory should be working dir assertEquals(myRepoViewUtil.getWorkdirItem(tree, repositoryFile) .getText(), wizardNode); waitInUI(); shell.close(); // start wizard from .git myRepoViewUtil.getWorkdirItem(tree, repositoryFile).expand().getNode( Constants.DOT_GIT).select(); ContextMenuHelper.clickContextMenu(tree, myUtil .getPluginLocalizedValue("ImportProjectsCommand")); shell = bot.shell(wizardTitle); selected = shell.bot().tree().selection(); wizardNode = selected.get(0, 0); // wizard directory should be .git assertEquals(Constants.DOT_GIT, wizardNode); shell.bot().button(IDialogConstants.NEXT_LABEL).click(); waitInUI(); assertTrue(shell.bot().tree().getAllItems().length == 0); shell.bot().button(IDialogConstants.BACK_LABEL).click(); // go to project with .project shell.bot().tree().getAllItems()[0].getNode(PROJ1).select(); // next is 1 shell.bot().button(IDialogConstants.NEXT_LABEL).click(); waitInUI(); assertTrue(shell.bot().tree().getAllItems().length == 1); assertTrue(!shell.bot().button(IDialogConstants.FINISH_LABEL) .isEnabled()); shell.bot().button(UIText.WizardProjectsImportPage_selectAll).click(); assertTrue(shell.bot().button(IDialogConstants.FINISH_LABEL) .isEnabled()); shell.bot().button(IDialogConstants.FINISH_LABEL).click(); waitInUI(); assertProjectExistence(PROJ1, true); }
From source file:org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestBase.java
License:Open Source License
protected static File createProjectAndCommitToRepository() throws Exception { File gitDir = new File(new File(getTestDirectory(), REPO1), Constants.DOT_GIT); gitDir.mkdir();//from ww w . j a v a 2s. co m Repository myRepository = lookupRepository(gitDir); myRepository.create(); // TODO Bug: for some reason, this seems to be required myRepository.getConfig().setString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_REPO_FORMAT_VERSION, "0"); myRepository.getConfig().save(); // we need to commit into master first IProject firstProject = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1); if (firstProject.exists()) firstProject.delete(true, null); IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(PROJ1); desc.setLocation(new Path(new File(myRepository.getWorkTree(), PROJ1).getPath())); firstProject.create(desc, null); firstProject.open(null); IFolder folder = firstProject.getFolder(FOLDER); folder.create(false, true, null); IFile textFile = folder.getFile(FILE1); textFile.create(new ByteArrayInputStream("Hello, world".getBytes(firstProject.getDefaultCharset())), false, null); IFile textFile2 = folder.getFile(FILE2); textFile2.create(new ByteArrayInputStream("Some more content".getBytes(firstProject.getDefaultCharset())), false, null); new ConnectProviderOperation(firstProject, gitDir).execute(null); IProject secondPoject = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ2); if (secondPoject.exists()) secondPoject.delete(true, null); desc = ResourcesPlugin.getWorkspace().newProjectDescription(PROJ2); desc.setLocation(new Path(new File(myRepository.getWorkTree(), PROJ2).getPath())); secondPoject.create(desc, null); secondPoject.open(null); IFolder secondfolder = secondPoject.getFolder(FOLDER); secondfolder.create(false, true, null); IFile secondtextFile = secondfolder.getFile(FILE1); secondtextFile.create(new ByteArrayInputStream("Hello, world".getBytes(firstProject.getDefaultCharset())), false, null); IFile secondtextFile2 = secondfolder.getFile(FILE2); secondtextFile2.create( new ByteArrayInputStream("Some more content".getBytes(firstProject.getDefaultCharset())), false, null); new ConnectProviderOperation(secondPoject, gitDir).execute(null); IFile[] commitables = new IFile[] { firstProject.getFile(".project"), textFile, textFile2, secondtextFile, secondtextFile2 }; ArrayList<IFile> untracked = new ArrayList<IFile>(); untracked.addAll(Arrays.asList(commitables)); // commit to stable CommitOperation op = new CommitOperation(commitables, new ArrayList<IFile>(), untracked, "Test Author <test.author@test.com>", "Test Committer <test.commiter@test.com>", "Initial commit"); op.execute(null); // now create a stable branch (from master) createStableBranch(myRepository); // and check in some stuff into master again touchAndSubmit(null); return gitDir; }
From source file:org.eclipse.egit.ui.view.synchronize.AbstractSynchronizeViewTest.java
License:Open Source License
protected void createEmptyRepository() throws Exception { File gitDir = new File(new File(getTestDirectory(), EMPTY_REPOSITORY), Constants.DOT_GIT); Repository myRepository = new FileRepository(gitDir); myRepository.create();//from w ww . j a v a 2s . co m // we need to commit into master first IProject firstProject = ResourcesPlugin.getWorkspace().getRoot().getProject(EMPTY_PROJECT); if (firstProject.exists()) firstProject.delete(true, null); IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(EMPTY_PROJECT); desc.setLocation(new Path(new File(myRepository.getWorkTree(), EMPTY_PROJECT).getPath())); firstProject.create(desc, null); firstProject.open(null); IFolder folder = firstProject.getFolder(FOLDER); folder.create(false, true, null); IFile textFile = folder.getFile(FILE1); textFile.create(new ByteArrayInputStream("Hello, world".getBytes(firstProject.getDefaultCharset())), false, null); IFile textFile2 = folder.getFile(FILE2); textFile2.create(new ByteArrayInputStream("Some more content".getBytes(firstProject.getDefaultCharset())), false, null); new ConnectProviderOperation(firstProject, gitDir).execute(null); }
From source file:org.eclipse.egit.ui.view.synchronize.SynchronizeViewRemoteAwareChangeSetModelTest.java
License:Open Source License
protected void createMockLogicalRepository() throws Exception { File gitDir = new File(new File(getTestDirectory(), MOCK_LOGICAL_PROJECT), Constants.DOT_GIT); Repository repo = FileRepositoryBuilder.create(gitDir); repo.create();/*ww w . j av a2s . c o m*/ // we need to commit into master first IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(MOCK_LOGICAL_PROJECT); if (project.exists()) { project.delete(true, null); TestUtil.waitForJobs(100, 5000); } IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(MOCK_LOGICAL_PROJECT); desc.setLocation(new Path(new File(repo.getWorkTree(), MOCK_LOGICAL_PROJECT).getPath())); project.create(desc, null); project.open(null); assertTrue("Project is not accessible: " + project, project.isAccessible()); TestUtil.waitForJobs(50, 5000); try { new ConnectProviderOperation(project, gitDir).execute(null); } catch (Exception e) { Activator.logError("Failed to connect project to repository", e); } assertConnected(project); mockLogicalFile = project.getFile("index.mocklogical"); mockLogicalFile.create( new ByteArrayInputStream("file1.txt\nfile2.txt".getBytes(project.getDefaultCharset())), false, null); IFile file1 = project.getFile("file1.txt"); file1.create(new ByteArrayInputStream("Content 1".getBytes(project.getDefaultCharset())), false, null); IFile file2 = project.getFile("file2.txt"); file2.create(new ByteArrayInputStream("Content 2".getBytes(project.getDefaultCharset())), false, null); IFile[] commitables = new IFile[] { mockLogicalFile, file1, file2 }; List<IFile> untracked = new ArrayList<>(); untracked.addAll(Arrays.asList(commitables)); CommitOperation op = new CommitOperation(commitables, untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER, "Initial commit"); op.execute(null); RevCommit firstCommit = op.getCommit(); CreateLocalBranchOperation createBranchOp = new CreateLocalBranchOperation(repo, "refs/heads/stable", firstCommit); createBranchOp.execute(null); // Delete file2.txt from logical model and add file3 mockLogicalFile = touch(MOCK_LOGICAL_PROJECT, "index.mocklogical", "file1.txt\nfile3.txt"); file2.delete(true, null); touch(MOCK_LOGICAL_PROJECT, "file1.txt", "Content 1 modified"); IFile file3 = project.getFile("file3.txt"); file3.create(new ByteArrayInputStream("Content 3".getBytes(project.getDefaultCharset())), false, null); commitables = new IFile[] { mockLogicalFile, file1, file2, file3 }; untracked = new ArrayList<>(); untracked.add(file3); op = new CommitOperation(commitables, untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER, "Second commit"); op.execute(null); }
From source file:org.eclipse.egit.ui.wizards.clone.GitCloneWizardTest.java
License:Open Source License
@Test public void alteringSomeParametersDuringClone() throws Exception { File destRepo = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), "test2"); importWizard.openWizard();/*from w ww. j a va2s .com*/ RepoPropertiesPage repoProperties = importWizard.openCloneWizard(); RepoRemoteBranchesPage remoteBranches = repoProperties.nextToRemoteBranches(r.getUri()); remoteBranches.deselectAllBranches(); remoteBranches.assertErrorMessage("At least one branch must be selected."); remoteBranches.assertNextIsDisabled(); remoteBranches.selectBranches(SampleTestRepository.FIX); remoteBranches.assertNextIsEnabled(); WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy(); workingCopy.setDirectory(destRepo.toString()); workingCopy.assertBranch(SampleTestRepository.FIX); workingCopy.setRemoteName("src"); workingCopy.waitForCreate(); // Some random sampling to see we got something. We do not test // the integrity of the repository here. Only a few basic properties // we'd expect from a clone made this way, that would possibly // not hold true given other parameters in the GUI. Repository repository = new FileRepository(new File(destRepo, Constants.DOT_GIT)); assertNotNull(repository.resolve("src/" + SampleTestRepository.FIX)); // we didn't clone that one assertNull(repository.resolve("src/master")); // and a local master initialized from origin/master (default!) assertEquals(repository.resolve("stable"), repository.resolve("src/stable")); // A well known tag assertNotNull(repository.resolve(Constants.R_TAGS + SampleTestRepository.v2_0_name).name()); // lots of refs assertTrue(repository.getAllRefs().size() >= 4); }
From source file:org.eclipse.egit.ui.wizards.clone.GitCloneWizardTestBase.java
License:Open Source License
protected void cloneRepo(File destRepo, RepoRemoteBranchesPage remoteBranches) throws Exception { remoteBranches.assertRemoteBranches(SampleTestRepository.FIX, Constants.MASTER); remoteBranches.selectBranches(SampleTestRepository.FIX, Constants.MASTER); WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy(); workingCopy.setDirectory(destRepo.toString()); workingCopy.assertDirectory(destRepo.toString()); workingCopy.assertBranch(Constants.MASTER); workingCopy.assertRemoteName(Constants.DEFAULT_REMOTE_NAME); workingCopy.waitForCreate();/* w ww .j a v a2 s .co m*/ // Some random sampling to see we got something. We do not test // the integrity of the repository here. Only a few basic properties // we'd expect from a clone made this way, that would possibly // not hold true given other parameters in the GUI. Repository repository = new FileRepository(new File(destRepo, Constants.DOT_GIT)); // we always have an origin/master assertNotNull(repository.resolve("origin/master")); // and a local master initialized from origin/master (default!) assertEquals(repository.resolve("master"), repository.resolve("origin/master")); // A well known tag assertNotNull(repository.resolve(Constants.R_TAGS + SampleTestRepository.v1_0_name).name()); // lots of refs int refs = repository.getAllRefs().size(); assertTrue(refs >= 4); // and a known file in the working dir assertTrue(new File(destRepo, SampleTestRepository.A_txt_name).exists()); DirCacheEntry fileEntry = null; DirCache dc = repository.lockDirCache(); fileEntry = dc.getEntry(SampleTestRepository.A_txt_name); dc.unlock(); // check that we have the file in the index assertNotNull(fileEntry); // No project has been imported assertEquals(0, ResourcesPlugin.getWorkspace().getRoot().getProjects().length); }
From source file:org.eclipse.egit.ui.wizards.clone.SampleTestRepository.java
License:Open Source License
private TestRepository<FileRepository> createRepository() throws Exception { String gitdirName = "test" + System.currentTimeMillis() + Constants.DOT_GIT; File gitdir = new File(trash, gitdirName).getCanonicalFile(); FileRepository db = new FileRepository(gitdir); assertFalse(gitdir.exists());//from w ww .ja v a 2 s . co m db.create(); return new TestRepository<FileRepository>(db); }