List of usage examples for org.eclipse.jgit.lib Repository getConfig
@NonNull public abstract StoredConfig getConfig();
From source file:org.eclipse.egit.core.AdaptableFileTreeIterator.java
License:Open Source License
/** * Create a new iterator to traverse the work tree of the given repository * <p>//from www . j av a 2s. co m * The iterator will automatically adapt to a {@link ContainerTreeIterator} * when encountering directories what can be mapped into the given workspace * root. * * @param repository * the repository this iterator should traverse the working tree * of * @param workspaceRoot * the workspace root to check resource mapping against. */ public AdaptableFileTreeIterator(final Repository repository, final IWorkspaceRoot workspaceRoot) { super(repository.getWorkTree(), FS.DETECTED, repository.getConfig().get(WorkingTreeOptions.KEY)); root = workspaceRoot; }
From source file:org.eclipse.egit.core.ContainerTreeIterator.java
License:Open Source License
/** * Construct a new iterator from a container in the workspace. * <p>/*from w ww.jav a 2s. co m*/ * The iterator will support traversal over the named container, but only if * it is contained within a project which has the Git repository provider * connected and this resource is mapped into a Git repository. During the * iteration the paths will be automatically generated to match the proper * repository paths for this container's children. * * @param repository * repository the given base is mapped to * @param base * the part of the workspace the iterator will walk over. */ public ContainerTreeIterator(final Repository repository, final IContainer base) { super(computePrefix(base), repository.getConfig().get(WorkingTreeOptions.KEY)); node = base; init(entries()); }
From source file:org.eclipse.egit.core.ContainerTreeIterator.java
License:Open Source License
/** * Construct a new iterator from the workspace root. * <p>/*from w w w . j a v a2s. co m*/ * The iterator will support traversal over workspace projects that have * a Git repository provider connected and is mapped into a Git repository. * During the iteration the paths will be automatically generated to match * the proper repository paths for this container's children. * * @param repository * repository the given base is mapped to * @param root * the workspace root to walk over. */ public ContainerTreeIterator(final Repository repository, final IWorkspaceRoot root) { super("", repository.getConfig().get(WorkingTreeOptions.KEY)); //$NON-NLS-1$ node = root; init(entries()); }
From source file:org.eclipse.egit.core.internal.gerrit.GerritUtil.java
License:Open Source License
/** * If the repository is not bare and looks like it might be a Gerrit * repository, try to configure it such that EGit's Gerrit support is * enabled./*from ww w. j av a 2 s . c o m*/ * * @param repository * to try to configure */ public static void tryToAutoConfigureForGerrit(@NonNull Repository repository) { if (repository.isBare()) { return; } StoredConfig config = repository.getConfig(); boolean isGerrit = false; boolean changed = false; try { for (RemoteConfig remote : RemoteConfig.getAllRemoteConfigs(config)) { if (isGerritPush(remote)) { isGerrit = true; if (configureFetchNotes(remote)) { changed = true; remote.update(config); } } } } catch (URISyntaxException ignored) { // Ignore it here -- we're just trying to set up Gerrit support. } if (isGerrit) { if (config.getString(ConfigConstants.CONFIG_GERRIT_SECTION, null, ConfigConstants.CONFIG_KEY_CREATECHANGEID) != null) { // Already configured. } else { setCreateChangeId(config); changed = true; } if (changed) { try { config.save(); } catch (IOException e) { Activator.logError( MessageFormat.format(CoreText.GerritUtil_ConfigSaveError, repository.getDirectory()), e); } } } }
From source file:org.eclipse.egit.core.internal.ProjectReferenceImporterTest.java
License:Open Source License
private static void addRemote(Repository repository, String name, URIish url) throws IOException { StoredConfig config = repository.getConfig(); config.setString("remote", name, "url", url.toString()); config.save();/*from w w w. j a v a2 s . com*/ }
From source file:org.eclipse.egit.core.op.ConfigureFetchAfterCloneTask.java
License:Open Source License
/** * @param repository the cloned repository * @param monitor/*w ww . j a v a 2 s .c om*/ * @throws CoreException */ public void execute(Repository repository, IProgressMonitor monitor) throws CoreException { try { RemoteConfig configToUse = new RemoteConfig(repository.getConfig(), remoteName); if (fetchRefSpec != null) configToUse.addFetchRefSpec(new RefSpec(fetchRefSpec)); configToUse.update(repository.getConfig()); repository.getConfig().save(); Git git = new Git(repository); try { git.fetch().setRemote(remoteName).call(); } catch (Exception e) { Activator.logError(NLS.bind(CoreText.ConfigureFetchAfterCloneTask_couldNotFetch, fetchRefSpec), e); } } catch (Exception e) { throw new CoreException(Activator.error(e.getMessage(), e)); } }
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. c o 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.op.ConfigurePushAfterCloneTask.java
License:Open Source License
/** * @param repository// w w w. j a va 2s . c om * @param monitor * @throws CoreException */ public void execute(Repository repository, IProgressMonitor monitor) throws CoreException { try { RemoteConfig configToUse = new RemoteConfig(repository.getConfig(), remoteName); if (pushRefSpec != null) configToUse.addPushRefSpec(new RefSpec(pushRefSpec)); if (pushURI != null) configToUse.addPushURI(pushURI); configToUse.update(repository.getConfig()); repository.getConfig().save(); } catch (Exception e) { throw new CoreException(Activator.error(e.getMessage(), e)); } }
From source file:org.eclipse.egit.core.op.SetChangeIdTask.java
License:Open Source License
public void execute(Repository repository, IProgressMonitor monitor) throws CoreException { try {/* w ww .j ava 2s .c om*/ repository.getConfig().setBoolean(ConfigConstants.CONFIG_GERRIT_SECTION, null, ConfigConstants.CONFIG_KEY_CREATECHANGEID, createchangeid); repository.getConfig().save(); } catch (IOException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } }
From source file:org.eclipse.egit.core.op.SetRepositoryConfigPropertyTask.java
License:Open Source License
public void execute(Repository repository, IProgressMonitor monitor) throws CoreException { try {/* ww w. j a va2 s. com*/ repository.getConfig().setString(section, subsection, name, value); repository.getConfig().save(); } catch (IOException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } }