Example usage for org.eclipse.jgit.lib Repository exactRef

List of usage examples for org.eclipse.jgit.lib Repository exactRef

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Repository exactRef.

Prototype

@Nullable
public final Ref exactRef(String name) throws IOException 

Source Link

Document

Get a ref by name.

Usage

From source file:org.eclipse.egit.ui.internal.actions.PushBranchActionHandler.java

License:Open Source License

@Override
public boolean isEnabled() {
    Repository repository = getRepository();
    if (repository == null) {
        return false;
    }//from   w w  w.j ava2 s. c  o m
    try {
        Ref head = repository.exactRef(Constants.HEAD);
        if (head != null && head.getObjectId() != null) {
            return true;
        }
    } catch (IOException e) {
        Activator.logError(e.getMessage(), e);
    }
    return false;
}

From source file:org.eclipse.egit.ui.internal.actions.PushBranchActionHandler.java

License:Open Source License

private Ref getBranchRef(Repository repository) {
    try {/* w  w  w  .  j av a2 s  .c  o m*/
        String fullBranch = repository.getFullBranch();
        if (fullBranch != null && fullBranch.startsWith(Constants.R_HEADS))
            return repository.exactRef(fullBranch);
    } catch (IOException e) {
        Activator.handleError(e.getLocalizedMessage(), e, false);
    }
    return null;
}

From source file:org.eclipse.egit.ui.internal.actions.PushUpstreamOrBranchActionHandler.java

License:Open Source License

private static Ref getHeadIfSymbolic(Repository repository) {
    try {//  w w w . ja v a  2  s. co m
        Ref head = repository.exactRef(Constants.HEAD);
        if (head != null && head.isSymbolic())
            return head;
        else
            return null;
    } catch (IOException e) {
        return null;
    }
}