Skip to content

Instantly share code, notes, and snippets.

@punya
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save punya/39f83a1437515f5a2143 to your computer and use it in GitHub Desktop.
Save punya/39f83a1437515f5a2143 to your computer and use it in GitHub Desktop.
package gittests;
import org.assertj.core.api.Assertions;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
public final class GitTests {
@Rule
public final TemporaryFolder folder = new TemporaryFolder();
@Test
public void testSsh() throws GitAPIException, IOException {
testClone("git@github.com:palantir/gradle-miniconda-plugin.git");
}
@Test
public void testHttps() throws GitAPIException, IOException {
testClone("https://github.com/palantir/gradle-miniconda-plugin.git");
}
private void testClone(String remote) throws GitAPIException, IOException {
Git result = null;
try {
result = Git.cloneRepository()
.setURI(remote)
.setDirectory(folder.getRoot())
.call();
Assertions.assertThat(new File(folder.getRoot(), ".travis.yml")).exists();
} finally {
if (result != null) {
result.close();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment