List of usage examples for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_URL
String CONFIG_KEY_URL
To view the source code for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_URL.
Click Source Link
From source file:org.eclipse.mylyn.reviews.r4e_gerrit.internal.utils.R4EGerritServerUtility.java
License:Open Source License
/** * This method use the Gerrit from the git server in the workspace *//* ww w . j a v a 2 s.co m*/ private void addWorkspaceGerritRepo() { RepositoryUtil repoUtil = org.eclipse.egit.core.Activator.getDefault().getRepositoryUtil(); List<String> repoPaths = repoUtil.getConfiguredRepositories(); RepositoryCache repositoryCache = org.eclipse.egit.core.Activator.getDefault().getRepositoryCache(); Repository repo = null; for (String repoPath : repoPaths) { R4EGerritPlugin.Ftracer.traceInfo("List Gerrit repository: " + repoPath); File gitDir = new File(repoPath); if (!gitDir.exists()) { R4EGerritPlugin.Ftracer.traceInfo("Gerrit repository do not exist: " + gitDir.getPath()); continue; } try { repo = repositoryCache.lookupRepository(gitDir); R4EGerritPlugin.Ftracer.traceInfo("\trepository config after lookup: " + repo.getConfig()); } catch (IOException e) { e.printStackTrace(); } if (repo != null) { Config config = new Config(repo.getConfig()); //Look to get the remotes URL Set<String> remotes = config.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION); for (String remote : remotes) { String remoteURL = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION, remote, ConfigConstants.CONFIG_KEY_URL); R4EGerritPlugin.Ftracer.traceInfo("\t\t " + remote + " -> remoteURL: " + remoteURL); //Test if this is a Gerrit server and add it to the Dialogue combo String convertedRemoteURL = getReformatGerritServer(remoteURL); if (null != convertedRemoteURL) { TaskRepository taskRepo = new TaskRepository(GerritConnector.CONNECTOR_KIND, convertedRemoteURL); taskRepo.setRepositoryLabel(convertedRemoteURL); fResultTask.put(taskRepo, taskRepo.getRepositoryUrl()); adjustTemplatemanager(taskRepo); } } } } }
From source file:org.eclipse.orion.server.git.objects.Clone.java
License:Open Source License
@PropertyDescription(name = GitConstants.KEY_URL) private String getCloneUrl() { try {// w ww .j a v a 2 s . co m FileBasedConfig config = getRepository().getConfig(); String remoteUri = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION, Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL); if (remoteUri != null) return remoteUri; } catch (IOException e) { // ignore and skip Git URL } return null; }
From source file:org.eclipse.orion.server.git.servlets.GitCloneHandlerV1.java
License:Open Source License
private JSONObject toJSON(Entry<IPath, File> entry, URI baseLocation) throws URISyntaxException { IPath k = entry.getKey();// ww w .j a v a 2 s .c om JSONObject result = new JSONObject(); try { result.put(ProtocolConstants.KEY_ID, k); result.put(ProtocolConstants.KEY_NAME, k.segmentCount() == 1 ? WebProject.fromId(k.segment(0)).getName() : k.lastSegment()); IPath np = new Path(GitServlet.GIT_URI).append(GitConstants.CLONE_RESOURCE).append("file").append(k); //$NON-NLS-1$ URI location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment()); result.put(ProtocolConstants.KEY_LOCATION, location); np = new Path("file").append(k).makeAbsolute(); //$NON-NLS-1$ location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment()); result.put(ProtocolConstants.KEY_CONTENT_LOCATION, location); np = new Path(GitServlet.GIT_URI).append(GitConstants.REMOTE_RESOURCE).append("file").append(k); //$NON-NLS-1$ location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment()); result.put(GitConstants.KEY_REMOTE, location); np = new Path(GitServlet.GIT_URI).append(GitConstants.CONFIG_RESOURCE) .append(GitConstants.CLONE_RESOURCE).append("file").append(k); //$NON-NLS-1$ location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment()); result.put(GitConstants.KEY_CONFIG, location); np = new Path(GitServlet.GIT_URI).append(GitConstants.COMMIT_RESOURCE).append(Constants.HEAD) .append("file").append(k); //$NON-NLS-1$ location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment()); result.put(GitConstants.KEY_HEAD, location); np = new Path(GitServlet.GIT_URI).append(GitConstants.COMMIT_RESOURCE).append("file").append(k); //$NON-NLS-1$ location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment()); result.put(GitConstants.KEY_COMMIT, location); np = new Path(GitServlet.GIT_URI).append(GitConstants.BRANCH_RESOURCE).append("file").append(k); //$NON-NLS-1$ location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment()); result.put(GitConstants.KEY_BRANCH, location); np = new Path(GitServlet.GIT_URI).append(GitConstants.INDEX_RESOURCE).append("file").append(k); //$NON-NLS-1$ location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment()); result.put(GitConstants.KEY_INDEX, location); np = new Path(GitServlet.GIT_URI).append(GitConstants.STATUS_RESOURCE).append("file").append(k); //$NON-NLS-1$ location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment()); result.put(GitConstants.KEY_STATUS, location); try { FileBasedConfig config = new FileRepository(entry.getValue()).getConfig(); String remoteUri = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION, Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL); if (remoteUri != null) result.put(GitConstants.KEY_URL, remoteUri); } catch (IOException e) { // ignore and skip Git URL } } catch (JSONException e) { //cannot happen, we know keys and values are valid } return result; }
From source file:org.flowerplatform.web.git.GitUtils.java
License:Open Source License
@SuppressWarnings("restriction") public Object[] getFetchPushUpstreamDataRefSpecAndRemote(Repository repository) throws InvalidConfigurationException, NoHeadException, DetachedHeadException { String branchName;// ww w . ja v a2 s. c o m String fullBranch; try { fullBranch = repository.getFullBranch(); if (fullBranch == null) { throw new NoHeadException(JGitText.get().pullOnRepoWithoutHEADCurrentlyNotSupported); } if (!fullBranch.startsWith(Constants.R_HEADS)) { // we can not pull if HEAD is detached and branch is not // specified explicitly throw new DetachedHeadException(); } branchName = fullBranch.substring(Constants.R_HEADS.length()); } catch (IOException e) { throw new JGitInternalException(JGitText.get().exceptionCaughtDuringExecutionOfPullCommand, e); } // get the configured remote for the currently checked out branch // stored in configuration key branch.<branch name>.remote Config repoConfig = repository.getConfig(); String remote = repoConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REMOTE); if (remote == null) { // fall back to default remote remote = Constants.DEFAULT_REMOTE_NAME; } // get the name of the branch in the remote repository // stored in configuration key branch.<branch name>.merge String remoteBranchName = repoConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_MERGE); if (remoteBranchName == null) { String missingKey = ConfigConstants.CONFIG_BRANCH_SECTION + "." + branchName + "." + ConfigConstants.CONFIG_KEY_MERGE; throw new InvalidConfigurationException( MessageFormat.format(JGitText.get().missingConfigurationForKey, missingKey)); } // check if the branch is configured for pull-rebase boolean doRebase = repoConfig.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REBASE, false); final boolean isRemote = !remote.equals("."); //$NON-NLS-1$ String remoteUri; if (isRemote) { remoteUri = repoConfig.getString(ConfigConstants.CONFIG_REMOTE_SECTION, remote, ConfigConstants.CONFIG_KEY_URL); if (remoteUri == null) { String missingKey = ConfigConstants.CONFIG_REMOTE_SECTION + "." + remote + "." + ConfigConstants.CONFIG_KEY_URL; throw new InvalidConfigurationException( MessageFormat.format(JGitText.get().missingConfigurationForKey, missingKey)); } return new Object[] { fullBranch, remoteBranchName, remoteUri, doRebase }; } return null; }
From source file:org.jboss.tools.openshift.egit.internal.test.EGitUtilsTest.java
License:Open Source License
@Test public void canAddRemoteRepo() throws Exception { Repository repository = testRepository.getRepository(); String remoteName = "redhat"; String gitUri = "www.redhat.com"; EGitUtils.addRemoteTo(remoteName, gitUri, repository); StoredConfig config = repository.getConfig(); Set<String> subsections = config.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION); assertEquals(1, subsections.size()); assertTrue(subsections.contains(remoteName)); assertEquals(gitUri, config.getString(ConfigConstants.CONFIG_REMOTE_SECTION, remoteName, ConfigConstants.CONFIG_KEY_URL)); }