List of usage examples for org.eclipse.jgit.lib Repository toString
@Override
@NonNull
public String toString()
From source file:com.googlesource.gerrit.plugins.supermanifest.Utils.java
License:Apache License
public static byte[] readBlob(Repository repo, String idStr) throws IOException { try (ObjectReader reader = repo.newObjectReader()) { ObjectId id = repo.resolve(idStr); if (id == null) { throw new RevisionSyntaxException(String.format("repo %s does not have %s", repo.toString(), idStr), idStr);//from ww w . j a va 2 s .c o m } return reader.open(id).getCachedBytes(Integer.MAX_VALUE); } }
From source file:org.apache.stratos.cartridge.agent.artifact.deployment.synchronizer.git.impl.GitBasedArtifactRepository.java
License:Apache License
public static boolean addRemote(Repository repository, String remoteUrl) { boolean remoteAdded = false; StoredConfig config = repository.getConfig(); config.setString(GitDeploymentSynchronizerConstants.REMOTE, GitDeploymentSynchronizerConstants.ORIGIN, GitDeploymentSynchronizerConstants.URL, remoteUrl); config.setString(GitDeploymentSynchronizerConstants.REMOTE, GitDeploymentSynchronizerConstants.ORIGIN, GitDeploymentSynchronizerConstants.FETCH, GitDeploymentSynchronizerConstants.FETCH_LOCATION); config.setString(GitDeploymentSynchronizerConstants.BRANCH, GitDeploymentSynchronizerConstants.MASTER, GitDeploymentSynchronizerConstants.REMOTE, GitDeploymentSynchronizerConstants.ORIGIN); config.setString(GitDeploymentSynchronizerConstants.BRANCH, GitDeploymentSynchronizerConstants.MASTER, GitDeploymentSynchronizerConstants.MERGE, GitDeploymentSynchronizerConstants.GIT_REFS_HEADS_MASTER); try {/*from www.ja va 2 s . c o m*/ config.save(); remoteAdded = true; } catch (IOException e) { log.error( "Error in adding remote origin " + remoteUrl + " for local repository " + repository.toString(), e); } return remoteAdded; }
From source file:org.jboss.tools.feedhenry.ui.internal.util.GitUtil.java
License:Open Source License
private static UserConfig getUserConfig(Repository repository) throws CoreException { Assert.isNotNull(repository, "Could not get user configuration. No repository provided."); if (repository.getConfig() == null) { throw new CoreException(new Status(IStatus.ERROR, FHPlugin.PLUGIN_ID, NLS.bind("no user configuration (author, committer) are present in repository \"{0}\"", repository.toString()))); }/*from w w w.ja v a 2 s .c om*/ return repository.getConfig().get(UserConfig.KEY); }
From source file:org.jboss.tools.openshift.egit.core.EGitUtils.java
License:Open Source License
private static PushOperationResult push(Repository repository, RemoteConfig remoteConfig, boolean force, IProgressMonitor monitor) throws CoreException { try {/*from w w w . j av a2 s . c o m*/ if (remoteConfig == null) { throw new CoreException(createStatus(null, "Repository \"{0}\" has no remote repository configured", repository.toString())); } PushOperation op = createPushOperation(remoteConfig, repository, force); op.run(monitor); PushOperationResult pushResult = op.getOperationResult(); if (hasFailedEntries(pushResult)) { throw new CoreException(EGitCoreActivator.createErrorStatus(NLS.bind( "Could not push repository {0}: {1}", repository.toString(), getErrors(pushResult)), null)); } return pushResult; } catch (CoreException e) { throw e; } catch (Exception e) { throw new CoreException(createStatus(e, "Could not push repo {0}", repository.toString())); } }
From source file:org.jboss.tools.openshift.egit.core.EGitUtils.java
License:Open Source License
/** * Creates a push operation specification for the given push uris to the * given push operation specification.// w ww . j av a 2s .co m * * @param pushURIs * the push uri's * @param pushRefSpecs * the push ref specs * @param repository * the repository * @return the push operation specification * @throws CoreException * the core exception */ private static PushOperationSpecification createPushSpec(Collection<URIish> pushURIs, Collection<RefSpec> pushRefSpecs, Repository repository) throws CoreException { try { PushOperationSpecification pushSpec = new PushOperationSpecification(); for (URIish uri : pushURIs) { Collection<RemoteRefUpdate> remoteRefUpdates = Transport.open(repository, uri) .findRemoteRefUpdatesFor(pushRefSpecs); pushSpec.addURIRefUpdates(uri, remoteRefUpdates); } return pushSpec; } catch (NotSupportedException e) { throw new CoreException( createStatus(e, "Could not connect repository \"{0}\" to a remote", repository.toString())); } catch (IOException e) { throw new CoreException( createStatus(e, "Could not convert remote specifications for repository \"{0}\" to a remote", repository.toString())); } }
From source file:org.jboss.tools.openshift.egit.core.EGitUtils.java
License:Open Source License
/** * Gets the UserConfig from the given repository. The UserConfig of a repo * holds the default author and committer. * /*from w w w . jav a2 s. co m*/ * @param repository * the repository * @return the user configuration * @throws CoreException * * @see PersonIdent(Repository) * @see CommittHelper#calculateCommitInfo */ private static UserConfig getUserConfig(Repository repository) throws CoreException { Assert.isLegal(repository != null, "Could not get user configuration. No repository provided."); if (repository.getConfig() == null) { throw new CoreException(createStatus(null, "no user configuration (author, committer) are present in repository \"{0}\"", repository.toString())); } return repository.getConfig().get(UserConfig.KEY); }
From source file:org.jboss.tools.openshift.egit.core.EGitUtils.java
License:Open Source License
private static String getCurrentBranch(Repository repository) throws CoreException { String branch = null;/*w w w . ja v a 2 s . com*/ try { branch = repository.getBranch(); } catch (IOException e) { throw new CoreException( createStatus(e, "Could not get current branch on repository \"{0}\"", repository.toString())); } return branch; }
From source file:org.jboss.tools.openshift.egit.core.EGitUtils.java
License:Open Source License
/** * Returns all the remote configs from the given repository. * /*from ww w.ja v a 2 s .co m*/ * @param repository * the repository to retrieve the remote configs of * @return the remote configs that are available on the repository * @throws CoreException */ public static List<RemoteConfig> getAllRemoteConfigs(Repository repository) throws CoreException { if (repository == null) { return Collections.emptyList(); } try { return RemoteConfig.getAllRemoteConfigs(repository.getConfig()); } catch (URISyntaxException e) { throw new CoreException(createStatus(e, "Could not get all remote repositories for repository \"{0}\"", repository.toString())); } }
From source file:org.wso2.carbon.deployment.synchronizer.git.util.GitUtilities.java
License:Open Source License
/** * Adds the remote repository at remoteUrl to the given local repository * * @param repository Repository instance representing local repo * @param remoteUrl remote repository url * @return true if remote successfully added, else false *//* ww w . jav a 2s. co m*/ public static boolean addRemote(Repository repository, String remoteUrl) { boolean remoteAdded = false; StoredConfig config = repository.getConfig(); config.setString(GitDeploymentSynchronizerConstants.REMOTE, GitDeploymentSynchronizerConstants.ORIGIN, GitDeploymentSynchronizerConstants.URL, remoteUrl); config.setString(GitDeploymentSynchronizerConstants.REMOTE, GitDeploymentSynchronizerConstants.ORIGIN, GitDeploymentSynchronizerConstants.FETCH, GitDeploymentSynchronizerConstants.FETCH_LOCATION); config.setString(GitDeploymentSynchronizerConstants.BRANCH, GitDeploymentSynchronizerConstants.MASTER, GitDeploymentSynchronizerConstants.REMOTE, GitDeploymentSynchronizerConstants.ORIGIN); config.setString(GitDeploymentSynchronizerConstants.BRANCH, GitDeploymentSynchronizerConstants.MASTER, GitDeploymentSynchronizerConstants.MERGE, GitDeploymentSynchronizerConstants.GIT_REFS_HEADS_MASTER); try { config.save(); remoteAdded = true; } catch (IOException e) { log.error( "Error in adding remote origin " + remoteUrl + " for local repository " + repository.toString(), e); } return remoteAdded; }