List of usage examples for org.eclipse.jgit.transport URIish getHumanishName
public String getHumanishName() throws IllegalArgumentException
From source file:com.madgag.agit.CloneLauncherActivity.java
License:Open Source License
private File defaultRepoDirFor(URIish uri) { File reposDir = new File(Environment.getExternalStorageDirectory(), "git-repos"); try {//from w w w . ja v a 2 s . c om String suffix = bareRepoCheckbox.isChecked() ? DOT_GIT_EXT : ""; return new File(reposDir, uri.getHumanishName() + suffix); } catch (IllegalArgumentException e) { return new File(reposDir, "repo"); } }
From source file:org.eclipse.egit.core.internal.ProjectReferenceImporter.java
License:Open Source License
/** * @param gitUrl/* www . ja v a2s.com*/ * @param branch * the branch to check out * @param allBranches * all branches which should be checked out for this gitUrl * @return the directory where the project should be checked out */ private static IPath getWorkingDir(URIish gitUrl, String branch, Set<String> allBranches) { final IPath workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation(); final String humanishName = gitUrl.getHumanishName(); String extendedName; if (allBranches.size() == 1 || branch.equals(Constants.MASTER)) extendedName = humanishName; else extendedName = humanishName + "_" + branch; //$NON-NLS-1$ final IPath workDir = workspaceLocation.append(extendedName); return workDir; }
From source file:org.eclipse.orion.server.git.servlets.GitPullRequestHandlerV1.java
License:Open Source License
public static String[] parseSshGitUrl(String url) throws URISyntaxException { String user = "", project = ""; URIish uriish = new URIish(url); String[] scp = uriish.getPath().replaceFirst("^/", "").split("/", -1); ;// w w w.j a va2 s .c o m if (scp.length == 2) { user = scp[0]; project = uriish.getHumanishName(); } return new String[] { uriish.getHost(), user, project }; }
From source file:org.eclipse.orion.server.tests.servlets.git.GitTest.java
License:Open Source License
protected JSONObject clone(URIish uri, IPath workspacePath, IPath filePath, String name, String kh, char[] p) throws JSONException, IOException, SAXException, CoreException { // clone/*from w w w .j a v a 2 s. c o m*/ WebRequest request = getPostGitCloneRequest(uri, workspacePath, filePath, name, kh, p); WebResponse response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_ACCEPTED, response.getResponseCode()); String taskLocation = response.getHeaderField(ProtocolConstants.HEADER_LOCATION); assertNotNull(taskLocation); String cloneLocation = waitForTaskCompletion(taskLocation); // validate the clone metadata response = webConversation.getResponse(getGetRequest(cloneLocation)); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); JSONObject clones = new JSONObject(response.getText()); JSONArray clonesArray = clones.getJSONArray(ProtocolConstants.KEY_CHILDREN); assertEquals(1, clonesArray.length()); JSONObject clone = clonesArray.getJSONObject(0); String n = clone.getString(ProtocolConstants.KEY_NAME); if (filePath != null) assertTrue(filePath.segmentCount() == 2 && n.equals(WebProject.fromId(filePath.segment(1)).getName()) || n.equals(filePath.lastSegment())); if (workspacePath != null) if (name != null) assertEquals(name, n); else assertEquals(uri.getHumanishName(), n); assertCloneUri(clone.getString(ProtocolConstants.KEY_LOCATION)); assertFileUri(clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION)); assertRemoteUri(clone.getString(GitConstants.KEY_REMOTE)); assertBranchUri(clone.getString(GitConstants.KEY_BRANCH)); return clone; }
From source file:org.eclipse.orion.server.tests.servlets.git.GitTest.java
License:Open Source License
protected void assertRepositoryInfo(URIish uri, JSONObject result) throws JSONException { assertEquals(uri.toString(), result.getJSONObject("ErrorData").get("Url")); if (uri.getUser() != null) assertEquals(uri.getUser(), result.getJSONObject("ErrorData").get("User")); if (uri.getHost() != null) assertEquals(uri.getHost(), result.getJSONObject("ErrorData").get("Host")); if (uri.getHumanishName() != null) assertEquals(uri.getHumanishName(), result.getJSONObject("ErrorData").get("HumanishName")); if (uri.getPass() != null) assertEquals(uri.getPass(), result.getJSONObject("ErrorData").get("Password")); if (uri.getPort() > 0) assertEquals(uri.getPort(), result.getJSONObject("ErrorData").get("Port")); if (uri.getScheme() != null) assertEquals(uri.getScheme(), result.getJSONObject("ErrorData").get("Scheme")); }
From source file:org.flowerplatform.web.git.GitService.java
License:Open Source License
@RemoteInvocation public boolean cloneRepository(final ServiceInvocationContext context, List<PathFragment> selectedPath, String repositoryUrl, final List<String> selectedBranches, final String remoteName, final boolean cloneAllBranches) { tlCommand.set((InvokeServiceMethodServerCommand) context.getCommand()); final URIish uri; try {//ww w. j a v a 2s .c om uri = new URIish(repositoryUrl.trim()); } catch (URISyntaxException e) { context.getCommunicationChannel().appendOrSendCommand( new DisplaySimpleMessageClientCommand(CommonPlugin.getInstance().getMessage("error"), e.getReason(), DisplaySimpleMessageClientCommand.ICON_ERROR)); return false; } @SuppressWarnings("unchecked") final Pair<File, Object> node = (Pair<File, Object>) GenericTreeStatefulService .getNodeByPathFor(selectedPath, null); File gitReposFile = GitPlugin.getInstance().getUtils().getGitRepositoriesFile(node.a); final File mainRepo = GitPlugin.getInstance().getUtils() .getMainRepositoryFile(new File(gitReposFile, uri.getHumanishName()), true); final ProgressMonitor monitor = ProgressMonitor.create( GitPlugin.getInstance().getMessage("git.clone.monitor.title", uri), context.getCommunicationChannel()); monitor.beginTask(GitPlugin.getInstance().getMessage("git.clone.monitor.title", uri), 2); Job job = new Job( MessageFormat.format(GitPlugin.getInstance().getMessage("git.clone.monitor.title", uri), uri)) { @Override protected IStatus run(IProgressMonitor m) { Repository repository = null; try { CloneCommand cloneRepository = Git.cloneRepository(); cloneRepository.setNoCheckout(true); cloneRepository.setDirectory(mainRepo); cloneRepository.setProgressMonitor(new GitProgressMonitor(new SubProgressMonitor(monitor, 1))); cloneRepository.setRemote(remoteName); cloneRepository.setURI(uri.toString()); cloneRepository.setTimeout(30); cloneRepository.setCloneAllBranches(cloneAllBranches); cloneRepository.setCloneSubmodules(false); if (selectedBranches.size() > 0) { cloneRepository.setBranchesToClone(selectedBranches); } Git git = cloneRepository.call(); repository = git.getRepository(); // notify clients about changes dispatchContentUpdate(node); monitor.worked(1); } catch (Exception e) { if (repository != null) repository.close(); GitPlugin.getInstance().getUtils().delete(mainRepo.getParentFile()); if (monitor.isCanceled()) { return Status.OK_STATUS; } if (GitPlugin.getInstance().getUtils().isAuthentificationException(e)) { openLoginWindow(); return Status.OK_STATUS; } logger.debug(GitPlugin.getInstance().getMessage("git.cloneWizard.error", new Object[] { mainRepo.getName() }), e); context.getCommunicationChannel() .appendOrSendCommand(new DisplaySimpleMessageClientCommand( CommonPlugin.getInstance().getMessage("error"), GitPlugin.getInstance().getMessage("git.cloneWizard.error", new Object[] { mainRepo.getName() }), DisplaySimpleMessageClientCommand.ICON_ERROR)); return Status.CANCEL_STATUS; } finally { monitor.done(); if (repository != null) { repository.close(); } } return Status.OK_STATUS; } }; job.schedule(); return true; }
From source file:org.zend.sdkcli.internal.commands.GitCloneProjectCommand.java
License:Open Source License
protected File getDirectory(String repo) throws URISyntaxException { String dir = getDir();//from w w w . j a va 2 s . com if (dir != null) { File dirFile = new File(dir); if (dirFile.isAbsolute()) { return dirFile; } return new File(getCurrentDirectory(), dir); } URIish uri = new URIish(repo); return new File(getCurrentDirectory(), uri.getHumanishName()); }