Re: [jgit-dev] Parsing PUSH request via smart http
Thank you Shawn for the information.
I just would like to parse the information and send EVERYTHING to
/usr/lib/git-core/git-http-backend and that should provide the
answer/reply what I send back to the client.
It works pretty good, I just would like to get (parse) that information
from the request and store it into our (MySql) database.
Do I understand it correctly that there is no easy way doing it with jgit?
Is GitServlet as robust/fast as git-http-backend?
On 07.08.2012 16:25, Shawn Pearce wrote:
On Tue, Aug 7, 2012 at 5:19 AM, Zsolt Koppany <zkoppanylist@xxxxxxxxxxx> wrote:
we push via tomcat using smart http and need to parse (but ONLY parse) the
push requests: author, branch, commit text etc.
You want to read the information, and reply with what to the client?
Most modern clients expect a status report from the server that
indicates if the push was successful or not.
Which jgit class could I use to read/parse information from a
This isn't trivial. The pack protocol used is pretty complex. What you
probably really mean to do is use the GitServlet class from JGit to
handle the protocol. Configure a ReceivePackFactory on the GitServlet
that creates a ReceivePack instance and sets a PreReceiveHook.
When a push request is received, the ReceivePack will be created. It
will consume the input stream from the client, and write new objects
to the local Git repository. Once these are written and stored, the
PreReceiveHook will be invoked with a List of ReceiveCommand
indicating the branch names and new ObjectIds the client wants to set
the branches to. Your implementation of the hook interface can now use
RevWalk to parse the commit and inspect author and commit text. If you
don't like what you find, you can use ReceivePack to send an error
message to the client, and you can setResult on the ReceiveCommand to
reject the operation.
Here is what we receive from "git" client:
This is how (the unzipped) request starts and that is followed by bi
02e429248bc42b39cbdbabe4be676612956fd681 refs/heads/master^@ report-status
Yea, you don't want to parse this yourself.