Example #1
0
def applyPatch(patch, patchLevel="0", reactor=None):
    """
    Apply a patch to the current git repository.

    @param patch: Patch to apply
    @type patch: L{str}

    @param patchLevel: Number of directries to strip from paths in patch
    """
    proto = AccumulatingProtocol()
    done = Deferred()
    proto.closedDeferred = done

    def feedPatch(proto):
        proto.transport.write(patch)
        proto.transport.closeStdin()

    connectProtocol(
        ProcessEndpoint(reactor, "git",
                        ("git", "apply", "--index", "-p", patchLevel)),
        proto).addCallback(feedPatch)

    def eb(_):
        # Note, we can't print why git apply failed due to https://tm.tl/#6576
        proto.closedReason.trap(ConnectionDone)

    done.addCallback(eb)
    return done
Example #2
0
    def test_status(self):
        agent = Agent(reactor)
        response = yield agent.request("GET", b"http://localhost:9010/status")

        proto = AccumulatingProtocol()
        proto.closedDeferred = Deferred()
        response.deliverBody(proto)
        yield proto.closedDeferred

        payload = json.loads(proto.data)
        eq_(payload, {"status": "OK", "version": __version__})
Example #3
0
    def test_status(self):
        agent = Agent(reactor)
        response = yield agent.request("GET", b"http://localhost:9010/status")

        proto = AccumulatingProtocol()
        proto.closedDeferred = Deferred()
        response.deliverBody(proto)
        yield proto.closedDeferred

        payload = json.loads(proto.data)
        eq_(payload, {"status": "OK", "version": __version__})
Example #4
0
def applyPatch(patch, patchLevel="0", reactor=None):
    """
    Apply a patch to the current git repository.

    @param patch: Patch to apply
    @type patch: L{str}

    @param patchLevel: Number of directries to strip from paths in patch
    """
    proto = AccumulatingProtocol()
    done = Deferred()
    proto.closedDeferred = done
    def feedPatch(proto):
        proto.transport.write(patch)
        proto.transport.closeStdin()
    connectProtocol(
            ProcessEndpoint(reactor, "git", ("git", "apply", "--index",
                                             "-p", patchLevel)),
            proto).addCallback(feedPatch)
    def eb(_):
        # Note, we can't print why git apply failed due to https://tm.tl/#6576
        proto.closedReason.trap(ConnectionDone)
    done.addCallback(eb)
    return done