Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JGit MongoDB connector
Java
Branch: master

README.md

JGit MongoDB connector

This project is a JGit DHT implementation using MongoDB as the backing database that uses the Mongo Java Driver library for connecting to MongoDB.

Example

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());

Building from source

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

Dependencies

  • JGit
  • MongoDB Java Driver

License

MIT License

Something went wrong with that request. Please try again.