Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Parsing PUSH request via smart http

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
> InputStream/File?

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
> 008ace0ca0e815ef8e926b05b1a73e03f1cc1c64d030
> 02e429248bc42b39cbdbabe4be676612956fd681 refs/heads/master^@ report-status
> side-band-64k quiet0000PACK

Yea, you don't want to parse this yourself.

Back to the top