This project is a JGit DHT implementation using MongoDB as the backing database that uses the Mongo Java Driver library for connecting to MongoDB.
The code snippet below shows how to fetch the linux-2.6 Git repository into MongoDB using a JGit repository.
Repository repo = MongoDatabase.open("linux-26");
repo.create(true);
StoredConfig config = repo.getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish("git://github.com/mirrors/linux-2.6.git");
remoteConfig.addURI(uri);
remoteConfig.update(config);
config.save();
RefSpec spec = new RefSpec("refs/heads/*:refs/remotes/origin/*");
Git.wrap(repo).fetch().setRemote("origin").setRefSpecs(spec).call();
You could the walk the commits imported into MongoDB using the following:
Repository repo = MongoDatabase.open("linux-26");
RevWalk walk = new RevWalk(repo);
walk.markStart(walk.parseCommit(repo.resolve("origin/master")));
for (RevCommit commit : walk)
System.out.println(commit.getShortMessage());
The JGit-MongoDB connector can be built using Maven. The pom.xml to build the core plug-in is located at the root of the org.gitective.mongo folder.
cd jgit-mongo/org.gitective.mongo
mvn clean install
- JGit
- MongoDB Java Driver