post-receive hook seems to not working?
Hi,
Thanks a lot for these package.
It works perfectly when I am trying the example code you are providing:
var express = require("express");
var expressGit = require("express-git");
var app = express();
app.use("/git", expressGit.serve("path/torepos/", {
auto_init: true,
serve_static: true,
authorize: function (service, req, next) {
// Authorize a service
next();
}
});
app.on('post-receive', function (repo, changes) {
// Do something after a push
next();
});
app.listen(3000);
But I have two problems:
- First, it looks like there is a missing closing parenthesis in the example code (before the semicolon on line 11).
- Second, the post-receive hook seems to not working. The git push works successfully but the
app.on('post-receive',...is never called when the push is completed. Is it right?
I saw a closed issue (#2) related to this second problem. I am using express-git 0.7.0, but the expressGit.on() is not recognized (message: expressGit.on is not a function)
Even if am a software developper for years, I am a newbie in using node.js. Maybe I misunderstood something?
Thanks a lot for your answer. Jean-Christophe
up!
@fabrejc Try chaining the hooks with expressGit.serve. It worked for me. Also, there is no need for calling next(); inside the handlers.
The code would look like:
var express = require("express");
var expressGit = require("express-git");
var app = express();
app.use("/git", expressGit.serve("path/torepos/", {
auto_init: true,
serve_static: true,
authorize: function (service, req, next) {
// Authorize a service
next();
}
}).on('pre-receive', function (repo, changes) {
// Do something before a push
}).on('post-receive', function (repo, changes) {
// Do something after a push
}));
app.listen(3000);
@alxarch Thanks for your reply and code snippet. Unfortunately, it is too late as I choosed another approach for my development (my post was two years ago).
Thanks for your wonderful job on this package
hi @fabrejc, what approach did you choose?
Hi @everdrone , i finally decided to use the Python Flask framework to build my REST services. The git part of the services was inspired by http://stewartjpark.com/2015/01/02/implementing-a-git-http-server-in-python.html
Thanks! will definitely take a look!