Example usage for org.eclipse.jgit.util QuotedString BOURNE

List of usage examples for org.eclipse.jgit.util QuotedString BOURNE

Introduction

In this page you can find the example usage for org.eclipse.jgit.util QuotedString BOURNE.

Prototype

BourneStyle BOURNE

To view the source code for org.eclipse.jgit.util QuotedString BOURNE.

Click Source Link

Document

Quoting style used by the Bourne shell.

Usage

From source file:com.google.gerrit.server.git.PushReplication.java

License:Apache License

private void replicateProject(final URIish replicateURI, final String head) {
    SshSessionFactory sshFactory = SshSessionFactory.getInstance();
    RemoteSession sshSession;//from w w w.j  ava  2  s . c  o  m
    String projectPath = QuotedString.BOURNE.quote(replicateURI.getPath());

    if (!usingSSH(replicateURI)) {
        log.warn("Cannot create new project on remote site since the connection " + "method is not SSH: "
                + replicateURI.toString());
        return;
    }

    OutputStream errStream = createErrStream();
    String cmd = "mkdir -p " + projectPath + "&& cd " + projectPath + "&& git init --bare"
            + "&& git symbolic-ref HEAD " + QuotedString.BOURNE.quote(head);

    try {
        sshSession = sshFactory.getSession(replicateURI, null, FS.DETECTED, 0);
        Process proc = sshSession.exec(cmd, 0);
        proc.getOutputStream().close();
        StreamCopyThread out = new StreamCopyThread(proc.getInputStream(), errStream);
        StreamCopyThread err = new StreamCopyThread(proc.getErrorStream(), errStream);
        out.start();
        err.start();
        try {
            proc.waitFor();
            out.halt();
            err.halt();
        } catch (InterruptedException interrupted) {
            // Don't wait, drop out immediately.
        }
        sshSession.disconnect();
    } catch (IOException e) {
        log.error("Communication error when trying to replicate to: " + replicateURI.toString() + "\n"
                + "Error reported: " + e.getMessage() + "\n" + "Error in communication: "
                + errStream.toString());
    }
}

From source file:com.google.gerrit.sshd.SshLogLayout.java

License:Apache License

private void req(String key, StringBuffer buf, LoggingEvent event) {
    Object val = event.getMDC(key);
    buf.append(' ');
    if (val != null) {
        String s = val.toString();
        if (0 <= s.indexOf(' ')) {
            buf.append(QuotedString.BOURNE.quote(s));
        } else {//from w w  w. j  a v  a 2 s. c o  m
            buf.append(val);
        }
    } else {
        buf.append('-');
    }
}

From source file:com.googlesource.gerrit.plugins.replication.ReplicationQueue.java

License:Apache License

private void createRemoteSsh(URIish uri, String head) {
    String quotedPath = QuotedString.BOURNE.quote(uri.getPath());
    String cmd = "mkdir -p " + quotedPath + " && cd " + quotedPath + " && git init --bare";
    if (head != null) {
        cmd = cmd + " && git symbolic-ref HEAD " + QuotedString.BOURNE.quote(head);
    }/*  w w  w. j  a va2s.  c om*/
    OutputStream errStream = newErrorBufferStream();
    try {
        executeRemoteSsh(uri, cmd, errStream);
    } catch (IOException e) {
        repLog.error(String.format("Error creating remote repository at %s:\n" + "  Exception: %s\n"
                + "  Command: %s\n" + "  Output: %s", uri, e, cmd, errStream), e);
    }
}

From source file:com.googlesource.gerrit.plugins.replication.ReplicationQueue.java

License:Apache License

private void deleteRemoteSsh(URIish uri) {
    String quotedPath = QuotedString.BOURNE.quote(uri.getPath());
    String cmd = "rm -rf " + quotedPath;
    OutputStream errStream = newErrorBufferStream();
    try {//from  w  ww  .j a  v  a2s  .co  m
        executeRemoteSsh(uri, cmd, errStream);
    } catch (IOException e) {
        repLog.error(String.format("Error deleting remote repository at %s:\n" + "  Exception: %s\n"
                + "  Command: %s\n" + "  Output: %s", uri, e, cmd, errStream), e);
    }
}

From source file:com.googlesource.gerrit.plugins.replication.ReplicationQueue.java

License:Apache License

private void updateHeadRemoteSsh(URIish uri, String newHead) {
    String quotedPath = QuotedString.BOURNE.quote(uri.getPath());
    String cmd = "cd " + quotedPath + " && git symbolic-ref HEAD " + QuotedString.BOURNE.quote(newHead);
    OutputStream errStream = newErrorBufferStream();
    try {//  www .  j a v a2 s  .co m
        executeRemoteSsh(uri, cmd, errStream);
    } catch (IOException e) {
        repLog.error(String.format("Error updating HEAD of remote repository at %s to %s:\n"
                + "  Exception: %s\n" + "  Command: %s\n" + "  Output: %s", uri, newHead, e, cmd, errStream),
                e);
    }
}