Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High level API #140

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Propagate push errors up.
Peter Amstutz committed Jan 26, 2018
commit d9314f13f8c71ad3b97c5cef6ec9b5108ed304cb
12 changes: 11 additions & 1 deletion mixins/high-level.js
Original file line number Diff line number Diff line change
@@ -127,7 +127,17 @@ function highLevel(repo, uName, uPass, hostName) {
stream.take(putHashes);
} else {
pushStream.put({flush: true});
return callback('Push done.');
var takedone = function(_, response) {
if (response && response.progress) {
callback(response.progress);
}
if (response === null) {
return callback(null);
} else {
pushStream.take(takedone);
}
}
pushStream.take(takedone);
}
}

33 changes: 18 additions & 15 deletions net/git-send-pack.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// -*- mode: js; js-indent-level: 2; -*-
"use strict";

var makeChannel = require('culvert');
@@ -90,17 +91,17 @@ function sendPack(transport, onError) {
if (line.oldhash) {
var extra = "";
if (!capsSent) {
capsSent = true;
var caplist = [];
if (caps["ofs-delta"]) caplist.push("ofs-delta");
if (caps["thin-pack"]) caplist.push("thin-pack");
// if (caps["multi_ack_detailed"]) extra += " multi_ack_detailed";
// else if (caps["multi_ack"]) extra +=" multi_ack";
if (caps["side-band-64k"]) caplist.push("side-band-64k");
else if (caps["side-band"]) caplist.push("side-band");
// if (caps["agent"]) extra += " agent=" + agent;
if (caps.agent) extra += caplist.push("agent=" + caps.agent);
extra = "\0" + caplist.join(" ");
capsSent = true;
var caplist = [];
if (caps["ofs-delta"]) caplist.push("ofs-delta");
if (caps["thin-pack"]) caplist.push("thin-pack");
// if (caps["multi_ack_detailed"]) extra += " multi_ack_detailed";
// else if (caps["multi_ack"]) extra +=" multi_ack";
if (caps["side-band-64k"]) caplist.push("side-band-64k");
else if (caps["side-band"]) caplist.push("side-band");
// if (caps["agent"]) extra += " agent=" + agent;
if (caps.agent) extra += caplist.push("agent=" + caps.agent);
extra = "\0" + caplist.join(" ");
}
extra += "\n";
socket.put(line.oldhash + " " + line.newhash + " " + line.ref + extra);
@@ -112,9 +113,11 @@ function sendPack(transport, onError) {
function onPack(_, line) {
if (line.flush) {
socket.put(line);
socket.take(function (_, h) {
api.put(h);
});
var fwd = function(_, b) {
api.put(b);
socket.take(fwd);
}
socket.take(fwd);
} else {
socket.put({
noframe: line
@@ -136,4 +139,4 @@ function throwIt(err) {
throw err;
});
// throw err;
}
}
23 changes: 12 additions & 11 deletions net/transport-http.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// -*- mode: js; js-indent-level: 2; -*-
"use strict";

var makeChannel = require('culvert');
@@ -80,18 +81,18 @@ module.exports = function (request) {
}

function onWrite(item) {
if (item === undefined) return socket.put();
if (item === null || !item.flush) {
if (item !== null && item.noframe !== undefined) {
bodyParts.push(item.noframe);
} else {
bodyWrite(item);
}
}
socket.take(onWrite);
if (item === null || (!item.flush)) {
if ((item !== "done\n" || !bodyParts.length) ) return;
if (item === undefined) return socket.put();
if (item === null || !item.flush) {
if (item !== null && item.noframe !== undefined) {
bodyParts.push(item.noframe);
} else {
bodyWrite(item);
}
}
socket.take(onWrite);
if (item === null || (!item.flush)) {
if ((item !== "done\n" || !bodyParts.length) ) return;
}
var body = bodec.join(bodyParts);
bodyParts.length = 0;
request("POST", gitUrl + "/" + serviceName, headers, body, onResult);