List of usage examples for org.eclipse.jgit.lib StoredConfig unsetSection
public void unsetSection(String section, String subsection)
From source file:org.eclipse.orion.server.git.servlets.GitRemoteHandlerV1.java
License:Open Source License
private boolean handleDelete(HttpServletRequest request, HttpServletResponse response, String path) throws CoreException, IOException, URISyntaxException, JSONException, ServletException { Path p = new Path(path); if (p.segment(1).equals("file")) { //$NON-NLS-1$ // expected path: /gitapi/remote/{remote}/file/{path} String remoteName = p.segment(0); File gitDir = GitUtils.getGitDir(p.removeFirstSegments(1)); Repository db = new FileRepository(gitDir); StoredConfig config = db.getConfig(); config.unsetSection(ConfigConstants.CONFIG_REMOTE_SECTION, remoteName); config.save();//from w ww . ja v a2 s . c o m //TODO: handle result return true; } return false; }
From source file:org.eclipse.orion.server.git.servlets.GitSubmoduleHandlerV1.java
License:Open Source License
public static void removeSubmodule(Repository db, Repository parentRepo, String pathToSubmodule) throws Exception { pathToSubmodule = pathToSubmodule.replace("\\", "/"); StoredConfig gitSubmodulesConfig = getGitSubmodulesConfig(parentRepo); gitSubmodulesConfig.unsetSection(CONFIG_SUBMODULE_SECTION, pathToSubmodule); gitSubmodulesConfig.save();/*from w ww. j a v a 2s .c om*/ StoredConfig repositoryConfig = parentRepo.getConfig(); repositoryConfig.unsetSection(CONFIG_SUBMODULE_SECTION, pathToSubmodule); repositoryConfig.save(); Git git = Git.wrap(parentRepo); git.add().addFilepattern(DOT_GIT_MODULES).call(); RmCommand rm = git.rm().addFilepattern(pathToSubmodule); if (gitSubmodulesConfig.getSections().size() == 0) { rm.addFilepattern(DOT_GIT_MODULES); } rm.call(); FileUtils.delete(db.getWorkTree(), FileUtils.RECURSIVE); FileUtils.delete(db.getDirectory(), FileUtils.RECURSIVE); }
From source file:org.flowerplatform.web.git.GitService.java
License:Open Source License
@RemoteInvocation public boolean deleteRemote(ServiceInvocationContext context, List<PathFragment> path) { try {//w w w. ja v a 2 s .c o m RemoteNode remoteNode = (RemoteNode) GenericTreeStatefulService.getNodeByPathFor(path, null); Repository repository = remoteNode.getRepository(); GenericTreeStatefulService service = GenericTreeStatefulService.getServiceFromPathWithRoot(path); NodeInfo remoteNodeInfo = service.getVisibleNodes().get(remoteNode); if (repository == null) { context.getCommunicationChannel() .appendOrSendCommand(new DisplaySimpleMessageClientCommand( CommonPlugin.getInstance().getMessage("error"), "Cannot find repository for node " + remoteNode, DisplaySimpleMessageClientCommand.ICON_ERROR)); return false; } StoredConfig config = repository.getConfig(); config.unsetSection("remote", remoteNode.getRemote()); config.save(); dispatchContentUpdate(remoteNodeInfo.getParent().getNode()); return true; } catch (Exception e) { logger.debug(GitPlugin.getInstance().getMessage("git.deleteRemote.error"), e); context.getCommunicationChannel().appendOrSendCommand( new DisplaySimpleMessageClientCommand(CommonPlugin.getInstance().getMessage("error"), GitPlugin.getInstance().getMessage("git.deleteRemote.error"), e.getMessage(), DisplaySimpleMessageClientCommand.ICON_ERROR)); return false; } }