Example usage for org.eclipse.jgit.lib Constants R_REMOTES

List of usage examples for org.eclipse.jgit.lib Constants R_REMOTES

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants R_REMOTES.

Prototype

String R_REMOTES

To view the source code for org.eclipse.jgit.lib Constants R_REMOTES.

Click Source Link

Document

Prefix for remotes refs

Usage

From source file:de.br0tbox.gitfx.ui.controllers.SingleProjectController.java

License:Apache License

private void addBranchesToView() {
    treeView.showRootProperty().set(false);
    branchesItem.getChildren().clear();/*ww w.  j  a  v  a2s.  c om*/
    remotesItem.getChildren().clear();
    tagsItem.getChildren().clear();
    final List<String> localList = projectModel.getLocalBranchesProperty();
    final List<String> remoteList = projectModel.getRemoteBranchesProperty();
    final List<String> tagsList = projectModel.getTagsProperty();
    for (String local : localList) {
        if (local.startsWith(Constants.R_HEADS)) {
            local = local.substring(Constants.R_HEADS.length(), local.length());
        }
        branchesItem.getChildren().add(new TreeItem(local));
    }
    for (String remote : remoteList) {
        if (remote.startsWith(Constants.R_REMOTES)) {
            remote = remote.substring(Constants.R_REMOTES.length(), remote.length());
        }
        remotesItem.getChildren().add(new TreeItem(remote));
    }
    for (String tag : tagsList) {
        if (tag.startsWith(Constants.R_TAGS)) {
            tag = tag.substring(Constants.R_TAGS.length(), tag.length());
        }
        tagsItem.getChildren().add(new TreeItem(tag));
    }
    branchesItem.expandedProperty().set(true);
    remotesItem.expandedProperty().set(true);
    tagsItem.expandedProperty().set(true);
}

From source file:de.br0tbox.gitfx.ui.history.JavaFxPlotRenderer.java

License:Apache License

@Override
protected int drawLabel(int x, int y, Ref ref) {
    String refName = ref.getName();
    if (refName.contains(Constants.R_HEADS)) {
        refName = refName.substring(Constants.R_HEADS.length(), refName.length());
    }//from  ww  w .  jav  a  2s.  co  m
    if (refName.contains(Constants.R_REMOTES)) {
        refName = refName.substring(Constants.R_REMOTES.length(), refName.length());
    }
    if (refName.contains(Constants.R_TAGS)) {
        refName = refName.substring(Constants.R_TAGS.length(), refName.length());
    }
    final Text text = new Text(refName);
    text.setX(x);
    text.setY(y * 1.5);
    text.setFill(Color.RED);
    final double fontSize = text.getFont().getSize();
    final int width = (int) Math.floor(fontSize * refName.trim().length() / 2);
    // final Rectangle rectangle = RectangleBuilder.create().x(x).y(y /
    // 2).width(width).height(fontSize + 3).fill(Color.RED).build();
    // currentShape.getChildren().add(rectangle);
    currentShape.getChildren().add(text);
    return (int) Math.floor(10 + width);
}

From source file:de.br0tbox.gitfx.ui.sync.SynchronizationTask.java

License:Apache License

private void refreshBranches() throws IOException {
    final List<String> remoteList = new ArrayList<>();
    final List<String> tagsList = new ArrayList<>();
    final List<String> localList = new ArrayList<>();
    final Repository repository = projectModel.getFxProject().getGit().getRepository();
    final Map<String, Ref> remotes = repository.getRefDatabase().getRefs(Constants.R_REMOTES);
    final Iterator<String> remotesIterator = remotes.keySet().iterator();
    while (remotesIterator.hasNext()) {
        final String remotekey = remotesIterator.next();
        final Ref remote = remotes.get(remotekey);
        remoteList.add(remote.getName());
    }//  w  w w  .  ja v  a  2s.  co m
    final Map<String, Ref> tags = repository.getRefDatabase().getRefs(Constants.R_TAGS);
    final Iterator<String> tagsIterator = tags.keySet().iterator();
    while (tagsIterator.hasNext()) {
        final String tagkey = tagsIterator.next();
        final Ref tag = tags.get(tagkey);
        tagsList.add(tag.getName());
    }
    final Map<String, Ref> all = repository.getRefDatabase().getRefs(Constants.R_REFS);
    final Iterator<String> allIterator = all.keySet().iterator();
    while (allIterator.hasNext()) {
        final String allKey = allIterator.next();
        final Ref allRef = all.get(allKey);
        if (allRef != null) {
            final String name = allRef.getName();
            if (!remoteList.contains(name) && !tagsList.contains(name)) {
                localList.add(name);
            }
        }
    }
    Platform.runLater(new Runnable() {

        @Override
        public void run() {
            projectModel.getLocalBranchesProperty().clear();
            projectModel.getLocalBranchesProperty().addAll(localList);
            projectModel.getRemoteBranchesProperty().clear();
            projectModel.getRemoteBranchesProperty().addAll(remoteList);
            projectModel.getTagsProperty().clear();
            projectModel.getTagsProperty().addAll(tagsList);
        }
    });
}

From source file:jbyoshi.gitupdate.processor.FastForward.java

License:Apache License

@Override
public void process(Repository repo, Git git, String branch, Ref ref, Report report)
        throws GitAPIException, IOException {
    String pushDefault = Utils.getPushRemote(repo, branch);
    if (pushDefault != null) {
        tryFastForward(repo, ref, repo.getRef(Constants.R_REMOTES + pushDefault + "/" + branch), report);
    }//from w w w.  j  a  va 2 s.  c om
    tryFastForward(repo, ref, repo.getRef(new BranchConfig(repo.getConfig(), branch).getTrackingBranch()),
            report);
    if (pushDefault == null) {
        tryFastForward(repo, ref, repo.getRef(Constants.R_REMOTES + "upstream/" + branch), report);
    }
}

From source file:jbyoshi.gitupdate.processor.RemoteProcessor.java

License:Apache License

@Override
public void registerTasks(Repository repo, Git git, Task root) throws Exception {
    Task me = root.newChild(getClass().getSimpleName());
    for (String remote : repo.getRemoteNames()) {
        me.newChild(remote, report -> {
            try {
                process(repo, git, remote, Constants.R_REMOTES + remote + "/", report);
            } catch (Exception e) {
                report.newErrorChild(e);
            }/*from   ww w.  j a v  a 2s .co m*/
        });
    }
}

From source file:jbyoshi.gitupdate.Utils.java

License:Apache License

public static String getShortBranch(String fullBranch) {
    if (fullBranch.startsWith(Constants.R_HEADS)) {
        return fullBranch.substring(Constants.R_HEADS.length());
    }//from w w w  .java 2s . c  om
    if (fullBranch.startsWith(Constants.R_REMOTES)) {
        return fullBranch.substring(Constants.R_REMOTES.length());
    }
    return fullBranch;
}

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;/* www . java 2s. 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:net.erdfelt.android.sdkfido.git.internal.GitCloneCommand.java

License:Apache License

/**
 * Add a 'remote' configuration./*ww w .ja  va 2s  .c  o m*/
 * 
 * @param remoteName
 *            the name of the remote
 * @param uri
 *            the uri to the remote
 * @throws URISyntaxException
 *             if unable to process uri
 * @throws IOException
 *             if unable to add remote config
 */
private void addRemoteConfig(String remoteName, URIish uri) throws URISyntaxException, IOException {
    RemoteConfig rc = new RemoteConfig(repo.getConfig(), remoteName);
    rc.addURI(uri);

    String dest = Constants.R_HEADS + "*:" + Constants.R_REMOTES + remoteName + "/*";

    RefSpec refspec = new RefSpec(dest);
    refspec.setForceUpdate(true);
    rc.addFetchRefSpec(refspec);
    rc.update(repo.getConfig());
    repo.getConfig().save();
}

From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java

License:Apache License

private static void infoRefs(Repository db) {
    Map<String, Ref> refs = db.getAllRefs();
    System.out.printf("%nAll Refs (%d)%n", refs.size());
    Ref head = refs.get(Constants.HEAD);

    if (head == null) {
        System.out.println(" HEAD ref is dead and/or non-existent?");
        return;/* ww w.  j  a v a2  s.  c om*/
    }

    Map<String, Ref> printRefs = new TreeMap<String, Ref>();

    String current = head.getLeaf().getName();
    if (current.equals(Constants.HEAD)) {
        printRefs.put("(no branch)", head);
    }

    for (Ref ref : RefComparator.sort(refs.values())) {
        String name = ref.getName();
        if (name.startsWith(Constants.R_HEADS) || name.startsWith(Constants.R_REMOTES)) {
            printRefs.put(name, ref);
        }
    }

    int maxLength = 0;
    for (String name : printRefs.keySet()) {
        maxLength = Math.max(maxLength, name.length());
    }

    System.out.printf("Refs (Heads/Remotes) (%d)%n", printRefs.size());
    for (Entry<String, Ref> e : printRefs.entrySet()) {
        Ref ref = e.getValue();
        ObjectId objectId = ref.getObjectId();
        System.out.printf("%c %-" + maxLength + "s %s%n", (current.equals(ref.getName()) ? '*' : ' '),
                e.getKey(), objectId.abbreviate(ABBREV_LEN).name());
    }
}