org.eclipse.jgit.api.InitCommand Java Examples
The following examples show how to use
org.eclipse.jgit.api.InitCommand.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitUtilsTest.java From orion.server with Eclipse Public License 1.0 | 6 votes |
@Test public void testGetGitDirWorkspaceIsInRepo() throws Exception { InitCommand command = new InitCommand(); File workspace = getWorkspaceRoot(); File parent = workspace.getParentFile(); command.setDirectory(parent); Repository repository = command.call().getRepository(); assertNotNull(repository); createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME); JSONObject project = createProjectOrLink(workspaceLocation, getMethodName().concat("Project"), null); String location = project.getString(ProtocolConstants.KEY_CONTENT_LOCATION); URI uri = URI.create(location); File dir = GitUtils.getGitDir(new Path(uri.getPath())); assertNull(dir == null ? "N/A" : dir.toURI().toURL().toString(), dir); File[] parentChildren = parent.listFiles(); for (int i = 0; i < parentChildren.length; i++) { if (parentChildren[i].getName().equals(".git")) { assertTrue(deleteDir(parentChildren[i])); } } }
Example #2
Source File: SystemTest.java From app-runner with MIT License | 6 votes |
@Test public void pushingAnEmptyRepoIsRejected() throws Exception { File dir = Photocopier.folderForSampleProject("empty-project"); InitCommand initCommand = Git.init(); initCommand.setDirectory(dir); Git origin = initCommand.call(); ContentResponse resp = restClient.createApp(dir.toURI().toString(), "empty-project"); assertThat(resp, equalTo(501, containsString("No suitable runner found for this app"))); Photocopier.copySampleAppToDir("maven", dir); origin.add().addFilepattern(".").call(); origin.commit().setMessage("Initial commit") .setAuthor(new PersonIdent("Author Test", "[email protected]")) .call(); resp = restClient.createApp(dir.toURI().toString(), "empty-project"); assertThat(resp, equalTo(201, containsString("empty-project"))); assertThat(new JSONObject(resp.getContentAsString()).get("name"), Matchers.equalTo("empty-project")); assertThat(restClient.deleteApp("empty-project"), equalTo(200, containsString("{"))); }
Example #3
Source File: AppRepo.java From app-runner with MIT License | 6 votes |
public static AppRepo create(String name, String sampleAppName) { try { File originDir = copySampleAppToTempDir(sampleAppName); InitCommand initCommand = Git.init(); initCommand.setDirectory(originDir); Git origin = initCommand.call(); origin.add().addFilepattern(".").call(); origin.commit().setMessage("Initial commit") .setAuthor(new PersonIdent("Author Test", "[email protected]")) .call(); return new AppRepo(name, originDir, origin); } catch (Exception e) { throw new RuntimeException("Error while creating git repo", e); } }
Example #4
Source File: TestProject.java From multi-module-maven-release-plugin with MIT License | 6 votes |
private static TestProject project(String name) { try { File originDir = copyTestProjectToTemporaryLocation(name); performPomSubstitution(originDir); InitCommand initCommand = Git.init(); initCommand.setDirectory(originDir); Git origin = initCommand.call(); origin.add().addFilepattern(".").call(); origin.commit().setMessage("Initial commit").call(); File localDir = Photocopier.folderForSampleProject(name); Git local = Git.cloneRepository() .setBare(false) .setDirectory(localDir) .setURI(originDir.toURI().toString()) .call(); return new TestProject(originDir, origin, localDir, local); } catch (Exception e) { throw new RuntimeException("Error while creating copies of the test project", e); } }
Example #5
Source File: GitCommitTest.java From app-runner with MIT License | 4 votes |
private static Git emptyRepo() throws GitAPIException { File dir = Photocopier.folderForSampleProject("blah"); InitCommand initCommand = Git.init(); initCommand.setDirectory(dir); return initCommand.call(); }