How to write or package a Git server as a Java Servlet or Java webapp?
Asked Answered
I

4

7

Git is clearly awesome and a variety of clients are both available and easy to install for all platforms.

However it's a bit of a challenge to get a Git server up and running for teams.

I'm a bit surprised that there is not yet an easily deploy-able Java-Git app server or webapp. It looks like Gitosis, Gitolite, etc. are some options running on other stacks, but if you’re already running a Java stack it would be easiest to just deploy a Java servlet or webapp.

Along these lines I was wondering how one would approach writing a Java ‘Git Server’ webapp?

How far could JGit get you for a simple implementation? What would one need to do to package JGit as a web app to be able to push/pull to it and from it as well as easily create new repos?

Injured answered 24/6, 2011 at 12:59 Comment(5)
Hi @Brendan, did you thought about using ssh as git server? It's quite convenient you only need some linux server and I suppose everyone can use cheap cloud hosting for that - it's better than run on windows box. Writing git server in java can be challenging project.Bemis
Hi Vladimir, Thanks for the suggestion. Yeah this is targeted at organizations that don't host in the cloud and keep their firewalls locked down (at least for now) - I think the vast majority of orgs won't post their source to the cloud. Also unfortunately a lot orgs DO use windows in their stack and this solves that at well. I know implementing a git server in java from scratch would be a lot of work but I think JGit already does a lot of what's needed. But I'm looking for guidance on the details around how to expose JGit as a webapp.Injured
"expose JGit (or Git for that matter)" as a webapp doesn't have a lot of value in itself. The "web" part in Git is only there for authentication. It can be a sshd, or an httpd, but beside that it simply pass the buck to Git itself, or to an authorization package like Gitolite. In any case, JGit wouldn't be involved. A simple "smart http" cgi (packaged with Git) is enough. See also #5683753Uranus
@Uranus Thanks for the great link and contributing thoughts. I think you're right about JGit not being part of this solution. However I still think the goal of easy deployment to a Java server stack (or your stack of choice) is a worthy one. I found this article Pro Git - Smart HTTP Transport which discusses one possible way using Grack+Warbler. The ultimate goal of course is drop a WAR file into your app server and get GitHub behind the firewall - though I must consider if there were more of a need I wouldn't be the only one asking :)Injured
quick note: get GitHub behind a firewall is something easily done with http.proxy config, plus a _netrc file (on Windows) with your GitHub credential in it. (https://mcmap.net/q/14306/-github-https-access) or https://mcmap.net/q/394238/-push-to-github-error-couldn-39-t-find-host-github-com-in-the-netrc-file-using-defaults, or in details: stackoverflow.com/questions/5378094#5378094. Smart http has always been important to me ;) stackoverflow.com/questions/2704113#2704113 and stackoverflow.com/questions/3207867#3207867 or stackoverflow.com/questions/3718246#3718246Uranus
G
3

Gerritt is deployable as a war file and uses JGit to provide the git server functionality. In addition to the standard git server functionality, is also supports access control and code review.

Gluttonize answered 29/6, 2011 at 23:38 Comment(1)
thanks! I had not realized Gerritt was a Git server, I thought it was only code review and had to be coupled with a Git server.Injured
S
6

SCM-Manager is a Git-Server written in Java and uses JGit.

Sartin answered 30/6, 2011 at 6:57 Comment(3)
Oh thanks! I had not found that in my searches. Much appreciated!!Injured
I downloaded scm-server-1.32-app.zip from scm-manager.org/download-action/?download=scm-server/1.32/… but it seems to be previous version, e.g. commits list is white HTML as if done by student during lab.Arcuation
I think you have the right version, but you are looking at the direct view of a git repository, which shows only the last few commits. If you want the nice looking commit view, you have to select the repository from the grid and click on commits on the bottom of the page. I think i will redirect from the repository url to this page in the next version.Sartin
L
4

Gitblit is an open-source, integrated, pure Java Git server, viewer, and repository manager for small workgroups. It works well on Windows and includes tools to run as a Windows service.

Laos answered 5/7, 2011 at 17:57 Comment(0)
G
3

Gerritt is deployable as a war file and uses JGit to provide the git server functionality. In addition to the standard git server functionality, is also supports access control and code review.

Gluttonize answered 29/6, 2011 at 23:38 Comment(1)
thanks! I had not realized Gerritt was a Git server, I thought it was only code review and had to be coupled with a Git server.Injured
P
-2

There is an implementation of Smart Http named GitServlet in JGit library. You can use following configuration to embed it your java based web application.

For configuration Refer:

http://www.jarvana.com/jarvana/view/com/madgag/org.eclipse.jgit.http.server/0.8.3-UNOFFICIAL-HARMONY-6637-FIX/org.eclipse.jgit.http.server-0.8.3-UNOFFICIAL-HARMONY-6637-FIX-javadoc.jar!/org/eclipse/jgit/http/server/GitServlet.html

Paton answered 10/10, 2011 at 12:48 Comment(1)
No point in providing link , as if link is invalid answer is lost. Current link is not accessible.Alaynaalayne

© 2022 - 2024 — McMap. All rights reserved.