List of usage examples for org.eclipse.jgit.internal.storage.file FileRepository getConfig
@Override
public FileBasedConfig getConfig()
From source file:com.tenxdev.ovcs.command.AbstractOvcsCommand.java
License:Open Source License
/** * gets an Oracle DB connection, based on connection string stored in the * local git repo's settings/* w w w . jav a 2 s . c om*/ * * @param repository * the local git repository * @return a JDBC connection to the database schema being tracked * @throws OvcsException */ protected Connection getDbConnectionForRepo(final FileRepository repository) throws OvcsException { final FileBasedConfig config = repository.getConfig(); final String connectionString = config.getString("database", null, "connectionString"); if (connectionString == null) { throw new OvcsException("The current git repository is not an OVCS repository"); } return getConnection(connectionString); }
From source file:org.eclipse.egit.core.internal.ProjectReferenceImporter.java
License:Open Source License
private static boolean repositoryAlreadyExistsForUrl(File repositoryPath, URIish gitUrl) { if (repositoryPath.exists()) { FileRepository existingRepository; try {//from ww w. j av a2 s. c om existingRepository = new FileRepository(repositoryPath); } catch (IOException e) { return false; } try { boolean exists = containsRemoteForUrl(existingRepository.getConfig(), gitUrl); return exists; } catch (URISyntaxException e) { return false; } finally { existingRepository.close(); } } return false; }
From source file:org.eclipse.egit.ui.submodule.SubmoduleSyncTest.java
License:Open Source License
@Test public void syncSubmodule() throws Exception { deleteAllProjects();//from w w w . jav 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); 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); String newUri = "git://server/repo.git"; File modulesFile = new File(repo.getWorkTree(), Constants.DOT_GIT_MODULES); FileBasedConfig config = new FileBasedConfig(modulesFile, repo.getFS()); config.load(); config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants.CONFIG_KEY_URL, newUri); config.save(); assertEquals(uri, repo.getConfig().getString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants.CONFIG_KEY_URL)); assertEquals(uri, subRepo.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION, Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL)); refreshAndWait(); SWTBotTree tree = getOrOpenView().bot().tree(); tree.getAllItems()[0].expand().expandNode(UIText.RepositoriesViewLabelProvider_SubmodulesNodeText).select(); ContextMenuHelper.clickContextMenuSync(tree, myUtil.getPluginLocalizedValue(SYNC_SUBMODULE_CONTEXT_MENU_LABEL)); TestUtil.joinJobs(JobFamilies.SUBMODULE_SYNC); refreshAndWait(); assertEquals(newUri, repo.getConfig().getString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants.CONFIG_KEY_URL)); assertEquals(newUri, subRepo.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION, Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL)); }
From source file:org.eclipse.egit.ui.view.synchronize.SynchronizeViewPushTest.java
License:Open Source License
@Before public void prepare() throws Exception { FileRepository childRepository = lookupRepository(childRepositoryFile); FileRepository repository = lookupRepository(repositoryFile); FileBasedConfig config = repository.getConfig(); RemoteConfig remoteConfig = new RemoteConfig(config, "origin"); remoteConfig.addURI(new URIish(childRepository.getDirectory().getParentFile().toURI().toURL())); remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*")); remoteConfig.update(config);/*from ww w . j a v a 2s . c om*/ config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REMOTE, "origin"); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_MERGE, "refs/heads/master"); config.save(); FetchOperation fetchOperation = new FetchOperation(repository, remoteConfig, 60, false); fetchOperation.run(null); }
From source file:org.sonatype.m2e.egit.internal.EgitScmHandler.java
License:Open Source License
protected void fixAutoCRLF(File gitDirectory) throws IOException { // jgit does not have support for core.autocrlf but it sets the core.autocrlf=false in the local git // repository config (https://bugs.eclipse.org/bugs/show_bug.cgi?id=301775). // We need to unset it. FileRepository localRepository = new FileRepository(gitDirectory); try {//from w w w .j a v a2 s. c om FileBasedConfig localConfig = localRepository.getConfig(); localConfig.unset(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF); localConfig.save(); } finally { localRepository.close(); } }