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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK, I will learn code deeper for cloning without http server(jgit servlet).
Thanks for help!