Created
February 23, 2012 17:48
-
-
Save timothyklim/1893998 to your computer and use it in GitHub Desktop.
JGit test with DHT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.eclipse.jgit.api.CloneCommand; | |
import org.eclipse.jgit.api.errors.InvalidRemoteException; | |
import org.eclipse.jgit.lib.Repository; | |
import org.eclipse.jgit.lib.StoredConfig; | |
import org.eclipse.jgit.transport.RemoteConfig; | |
import org.eclipse.jgit.transport.URIish; | |
import java.io.File; | |
import java.io.IOException; | |
import java.net.URISyntaxException; | |
public class Main { | |
static public void main(String[] args) throws IOException, URISyntaxException, InvalidRemoteException { | |
Repository repo = org.gitective.mongo.MongoDatabase.open("git_repo_test"); | |
try { | |
repo.create(true); | |
} | |
catch ( org.eclipse.jgit.storage.dht.DhtException e) {} | |
StoredConfig config = repo.getConfig(); | |
RemoteConfig remoteConfig = new RemoteConfig(config, "origin"); | |
URIish uri = new URIish("file://" + System.getProperty("user.dir") + "/test_git_repo"); | |
remoteConfig.addURI(uri); | |
remoteConfig.update(config); | |
config.save(); | |
repo.close(); | |
// This code works only for non-dht code, but how I can clone repo from MongoDB? :3 | |
// CloneCommand cloneCommand = new CloneCommand(); | |
// cloneCommand.setURI(repo.getDirectory().getPath()); | |
// cloneCommand.setDirectory(new File("/tmp/for_git_test")); | |
// cloneCommand.setBare(false); | |
// cloneCommand.call(); | |
} | |
} |
Yes, I want to clone repository that stored in MongoDB.
…On Feb 23, 2012, at 10:21 PM, Kevin Sawicki wrote:
So you want to clone an existing local repository into Mongo? Or clone a repository locally that is already stored in Mongo?
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1893998
There currently isn't a way to do this besides hosting the repository backed by mongo using the JGit http server and cloning from there. You would just need to the JGit HTTP server to use the Mongo repository.
OK, I will learn code deeper for cloning without http server(jgit servlet).
Thanks for help!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So you want to clone an existing local repository into Mongo? Or clone a repository locally that is already stored in Mongo?