Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

reject test passes with the new accept/reject event api

  • Loading branch information...
commit 16a360926778cef5aaadfb0960e9d0c8a9704251 1 parent bef80f7
James Halliday authored
12 lib/handle.js
View
@@ -27,10 +27,6 @@ handlers.push(function (req, res) {
var self = this;
var repo = m[1];
- var repopath = self.checkout
- ? path.join(self.repoDir, repo, '.git')
- : path.join(self.repoDir, repo)
- ;
var params = qs.parse(u.query);
if (!params.service) {
@@ -51,7 +47,7 @@ handlers.push(function (req, res) {
'application/x-git-' + service + '-advertisement'
);
noCache(res);
- serviceRespond(service, repopath, res);
+ serviceRespond(service, path.join(self.repoDir, repo), res);
};
self.exists(repo, function (ex) {
@@ -71,12 +67,7 @@ handlers.push(function (req, res) {
if (!m) return false;
var self = this;
-
var repo = m[1];
- var repopath = self.checkout
- ? path.join(self.repoDir, repo, '.git')
- : path.join(self.repoDir, repo)
- ;
var next = function () {
var file = path.join(repopath, 'HEAD');
@@ -118,6 +109,7 @@ handlers.push(function (req, res) {
noCache(res);
var action = createAction({
+ repo : repo,
service : service,
cwd : path.join(self.repoDir, repo)
}, req, res);
5 lib/service.js
View
@@ -16,6 +16,7 @@ function Service (opts, req, res) {
HttpDuplex.call(self, req, res);
self.status = 'pending';
+ self.repo = opts.repo;
self.service = opts.service;
self.cwd = opts.cwd;
@@ -45,7 +46,7 @@ function Service (opts, req, res) {
});
});
- self.on('accept', function () {
+ self.once('accept', function () {
process.nextTick(function () {
var ps = spawn('git-' + opts.service, [
'--stateless-rpc',
@@ -55,7 +56,7 @@ function Service (opts, req, res) {
ps.stdout.pipe(self, { end : !piped });
buffered.forEach(function (buf) {
- ps.write(buf);
+ ps.stdin.write(buf);
});
buffered = undefined;
2  test/autocreate.js
View
@@ -71,6 +71,6 @@ test('create, push to, and clone a repo', function (t) {
repos.on('push', function (push) {
t.equal(push.repo, 'doom');
- push.end();
+ push.accept();
});
});
25 test/reject.js
View
@@ -58,23 +58,26 @@ test('create, push to, and clone a repo', function (t) {
});
ps.stdout.pipe(process.stdout, { end : false });
})
- .seq(function () {
+ .seq_(function (next) {
var ps = spawn('git', [
'push', 'http://localhost:' + port + '/doom', 'master'
]);
ps.stderr.pipe(process.stderr, { end : false });
ps.on('exit', function (code) {
t.notEqual(code, 0);
-
- var glog = spawn('git', [ 'log' ], { cwd : repoDir + '/doom' });
- glog.on('exit', function (code) {
- t.notEqual(code, 0);
- });
- var data = '';
- glog.stderr.on('data', function (buf) { data += buf });
- glog.stderr.on('end', function (buf) {
- t.ok(/bad default revision 'HEAD'/.test(data));
- });
+ next();
+ });
+ })
+ .seq(setTimeout, seq, 1000)
+ .seq(function () {
+ var glog = spawn('git', [ 'log' ], { cwd : repoDir + '/doom' });
+ glog.on('exit', function (code) {
+ t.notEqual(code, 0);
+ });
+ var data = '';
+ glog.stderr.on('data', function (buf) { data += buf });
+ glog.stderr.on('end', function (buf) {
+ t.ok(/bad default revision 'HEAD'/.test(data));
});
})
.catch(t.fail)
2  test/repos.js
View
@@ -88,6 +88,6 @@ test('create, push to, and clone a repo', function (t) {
t.equal(push.method, 'POST', 'is a post');
t.equal(push.url, '/doom/git-receive-pack', 'receive pack');
- push.end();
+ push.accept();
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.