List of usage examples for org.eclipse.jgit.lib Constants R_REFS
String R_REFS
To view the source code for org.eclipse.jgit.lib Constants R_REFS.
Click Source Link
From source file:jenkins.plugins.git.traits.DiscoverOtherRefsTrait.java
License:Open Source License
@DataBoundConstructor public DiscoverOtherRefsTrait(String ref) { if (StringUtils.isEmpty(ref)) { throw new IllegalArgumentException("ref can not be empty"); }//from w ww . j a v a2 s .c om this.ref = StringUtils.removeStart(StringUtils.removeStart(ref, Constants.R_REFS), "/"); setDefaultNameMapping(); }
From source file:jenkins.plugins.git.traits.DiscoverOtherRefsTrait.java
License:Open Source License
String getFullRefSpec() { return new StringBuilder("+").append(Constants.R_REFS).append(ref).append(':').append(Constants.R_REMOTES) .append(REF_SPEC_REMOTE_NAME_PLACEHOLDER_STR).append('/').append(ref).toString(); }
From source file:kr.re.ec.grigit.graph.ui.AWTPlotRenderer.java
License:Eclipse Distribution License
@Override protected int drawLabel(int x, int y, Ref ref) { String txt;//from w ww . j av a2 s .c o m String name = ref.getName(); if (name.startsWith(Constants.R_HEADS)) { g.setBackground(Color.GREEN); txt = name.substring(Constants.R_HEADS.length()); } else if (name.startsWith(Constants.R_REMOTES)) { g.setBackground(Color.LIGHT_GRAY); txt = name.substring(Constants.R_REMOTES.length()); } else if (name.startsWith(Constants.R_TAGS)) { g.setBackground(Color.YELLOW); txt = name.substring(Constants.R_TAGS.length()); } else { // Whatever this would be g.setBackground(Color.WHITE); if (name.startsWith(Constants.R_REFS)) txt = name.substring(Constants.R_REFS.length()); else txt = name; // HEAD and such } if (ref.getPeeledObjectId() != null) { float[] colorComponents = g.getBackground().getRGBColorComponents(null); colorComponents[0] *= 0.9; colorComponents[1] *= 0.9; colorComponents[2] *= 0.9; g.setBackground(new Color(colorComponents[0], colorComponents[1], colorComponents[2])); } if (txt.length() > 12) txt = txt.substring(0, 11) + "\u2026"; // ellipsis "" (in UTF-8) //$NON-NLS-1$ final int texth = g.getFontMetrics().getHeight(); int textw = g.getFontMetrics().stringWidth(txt); g.setColor(g.getBackground()); int arcHeight = texth / 4; int y0 = y - texth / 2 + (cell.getHeight() - texth) / 2; g.fillRoundRect(x, y0, textw + arcHeight * 2, texth - 1, arcHeight, arcHeight); g.setColor(g.getColor().darker()); g.drawRoundRect(x, y0, textw + arcHeight * 2, texth - 1, arcHeight, arcHeight); g.setColor(Color.BLACK); g.drawString(txt, x + arcHeight, y0 + texth - g.getFontMetrics().getDescent()); return arcHeight * 3 + textw; }
From source file:org.eclipse.egit.core.op.BranchOperation.java
License:Open Source License
public void execute(IProgressMonitor m) throws CoreException { IProgressMonitor monitor;/*from ww w . ja va2 s. com*/ if (m == null) monitor = new NullProgressMonitor(); else monitor = m; if (refName != null && !refName.startsWith(Constants.R_REFS)) throw new TeamException(NLS.bind(CoreText.BranchOperation_CheckoutOnlyBranchOrTag, refName)); IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { IProject[] validProjects = ProjectUtil.getValidProjects(repository); pm.beginTask(NLS.bind(CoreText.BranchOperation_performingBranch, refName), 5); lookupRefs(); pm.worked(1); mapObjects(); pm.worked(1); checkoutTree(); pm.worked(1); updateHeadRef(); pm.worked(1); ProjectUtil.refreshValidProjects(validProjects, new SubProgressMonitor(pm, 1)); pm.worked(1); pm.done(); } }; // lock workspace to protect working tree changes ResourcesPlugin.getWorkspace().run(action, monitor); }
From source file:org.eclipse.egit.ui.internal.actions.PullFromUpstreamActionHandler.java
License:Open Source License
@Override public boolean isEnabled() { // we don't do the full canMerge check here, but // ensure that a branch is checked out Repository repo = getRepository();/* ww w .ja va2s. c o m*/ if (repo == null) return false; try { String fullBranch = repo.getFullBranch(); return (fullBranch.startsWith(Constants.R_REFS)); } catch (IOException e) { return false; } }
From source file:org.eclipse.egit.ui.internal.history.command.MergeHandler.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { RevCommit commit = (RevCommit) getSelection(getPage()).getFirstElement(); final Repository repository = getRepository(event); if (repository == null) return null; if (!canMerge(repository)) return null; List<RefNode> nodes = getRefNodes(commit, repository, Constants.R_REFS); String refName;//from ww w . j a v a 2 s . c om if (nodes.isEmpty()) refName = commit.getName(); else if (nodes.size() == 1) refName = nodes.get(0).getObject().getName(); else { BranchSelectionDialog<RefNode> dlg = new BranchSelectionDialog<RefNode>( HandlerUtil.getActiveShellChecked(event), nodes, UIText.MergeHandler_SelectBranchTitle, UIText.MergeHandler_SelectBranchMessage, SWT.SINGLE); if (dlg.open() == Window.OK) refName = dlg.getSelectedNode().getObject().getName(); else return null; } String jobname = NLS.bind(UIText.MergeAction_JobNameMerge, refName); final MergeOperation op = new MergeOperation(repository, refName); Job job = new Job(jobname) { @Override protected IStatus run(IProgressMonitor monitor) { try { op.execute(monitor); } catch (final CoreException e) { return e.getStatus(); } return Status.OK_STATUS; } }; job.setUser(true); job.setRule(op.getSchedulingRule()); job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent cevent) { IStatus result = cevent.getJob().getResult(); if (result.getSeverity() == IStatus.CANCEL) Display.getDefault().asyncExec(new Runnable() { public void run() { // don't use getShell(event) here since // the active shell has changed since the // execution has been triggered. Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialog.openInformation(shell, UIText.MergeAction_MergeCanceledTitle, UIText.MergeAction_MergeCanceledMessage); } }); else if (!result.isOK()) Activator.handleError(result.getMessage(), result.getException(), true); else Display.getDefault().asyncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MergeResultDialog.getDialog(shell, repository, op.getResult()).open(); } }); } }); job.schedule(); return null; }
From source file:org.eclipse.egit.ui.internal.history.SWTPlotRenderer.java
License:Open Source License
@Override protected int drawLabel(int x, int y, Ref ref) { String txt;//from w ww.j av a 2 s . com String name = ref.getName(); if (name.startsWith(Constants.R_HEADS)) { g.setBackground(sys_green); txt = name.substring(Constants.R_HEADS.length()); } else if (name.startsWith(Constants.R_REMOTES)) { g.setBackground(sys_gray); txt = name.substring(Constants.R_REMOTES.length()); } else if (name.startsWith(Constants.R_TAGS)) { g.setBackground(sys_yellow); txt = name.substring(Constants.R_TAGS.length()); } else { // Whatever this would be g.setBackground(sys_white); if (name.startsWith(Constants.R_REFS)) txt = name.substring(Constants.R_REFS.length()); else txt = name; // HEAD and such } // Make peeled objects, i.e. via annotated tags come out in a paler color Color peeledColor = null; if (ref.getPeeledObjectId() == null || !ref.getPeeledObjectId().equals(ref.getObjectId())) { peeledColor = new Color(g.getDevice(), ColorUtil.blend(g.getBackground().getRGB(), sys_white.getRGB())); g.setBackground(peeledColor); } if (txt.length() > 12) txt = txt.substring(0, 11) + "\u2026"; // ellipsis "" (in UTF-8) //$NON-NLS-1$ Point textsz = g.stringExtent(txt); int arc = textsz.y / 2; final int texty = (y * 2 - textsz.y) / 2; // Draw backgrounds g.fillRoundRectangle(cellX + x + 1, cellY + texty - 1, textsz.x + 3, textsz.y + 1, arc, arc); g.setForeground(sys_black); g.drawString(txt, cellX + x + 2, cellY + texty, true); g.setLineWidth(2); // And a two color shaded border, blend with whatever background there already is g.setAlpha(128); g.setForeground(sys_gray); g.drawRoundRectangle(cellX + x, cellY + texty - 2, textsz.x + 5, textsz.y + 3, arc, arc); g.setLineWidth(2); g.setForeground(sys_black); g.drawRoundRectangle(cellX + x + 1, cellY + texty - 1, textsz.x + 3, textsz.y + 1, arc, arc); g.setAlpha(255); if (peeledColor != null) peeledColor.dispose(); return 8 + textsz.x; }
From source file:org.eclipse.egit.ui.internal.pull.PullWizardPage.java
License:Open Source License
/** * @return the chosen short name of the branch on the remote *//*from w ww. j a v a2 s . c om*/ String getFullRemoteReference() { if (!remoteBranchNameText.getText().startsWith(Constants.R_REFS)) return Constants.R_HEADS + remoteBranchNameText.getText(); else return remoteBranchNameText.getText(); }
From source file:org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider.java
License:Open Source License
private Image decorateImage(final Image image, Object element) { RepositoryTreeNode node = (RepositoryTreeNode) element; switch (node.getType()) { case TAG://from w w w . j av a2 s.c om // fall through case ADDITIONALREF: // fall through case REF: // if the branch or tag is checked out, // we want to decorate the corresponding // node with a little check indicator String refName = ((Ref) node.getObject()).getName(); Ref leaf = ((Ref) node.getObject()).getLeaf(); String branchName; String compareString; try { branchName = node.getRepository().getFullBranch(); if (branchName == null) return image; if (refName.startsWith(Constants.R_HEADS)) { // local branch: HEAD would be on the branch compareString = refName; } else if (refName.startsWith(Constants.R_TAGS)) { // tag: HEAD would be on the commit id to which the tag is // pointing ObjectId id = node.getRepository().resolve(refName); if (id == null) return image; RevWalk rw = new RevWalk(node.getRepository()); RevTag tag = rw.parseTag(id); compareString = tag.getObject().name(); } else if (refName.startsWith(Constants.R_REMOTES)) { // remote branch: HEAD would be on the commit id to which // the branch is pointing ObjectId id = node.getRepository().resolve(refName); if (id == null) return image; RevWalk rw = new RevWalk(node.getRepository()); RevCommit commit = rw.parseCommit(id); compareString = commit.getId().name(); } else if (refName.equals(Constants.HEAD)) return getDecoratedImage(image); else { String leafname = leaf.getName(); if (leafname.startsWith(Constants.R_REFS) && leafname.equals(node.getRepository().getFullBranch())) return getDecoratedImage(image); else if (leaf.getObjectId().equals(node.getRepository().resolve(Constants.HEAD))) return getDecoratedImage(image); // some other symbolic reference return image; } } catch (IOException e1) { return image; } if (compareString.equals(branchName)) { return getDecoratedImage(image); } return image; default: return image; } }
From source file:org.eclipse.egit.ui.internal.repository.SelectResetTypePage.java
License:Open Source License
private boolean isCommit(final String ref) { return !ref.startsWith(Constants.R_REFS); }