org.eclipse.egit.github.core.CommitFile Java Examples
The following examples show how to use
org.eclipse.egit.github.core.CommitFile.
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: GithubDiffReader.java From cover-checker with Apache License 2.0 | 6 votes |
@Override public RawDiff next() { CommitFile file = files.next(); log.info("get file {}", file.getFilename()); List<String> lines; if (file.getPatch() != null && file.getPatch().length() > 0) { lines = Arrays.asList(file.getPatch().split("\r?\n")); } else { lines = Collections.emptyList(); } return RawDiff.builder() .fileName(file.getFilename()) .rawDiff(lines) .type(file.getPatch() != null ? FileType.SOURCE : FileType.BINARY) .build(); }
Example #2
Source File: GithubDiffParseTest.java From cover-checker with Apache License 2.0 | 6 votes |
@Test public void parsedGithubDiff() throws IOException { GithubPullRequestManager mockPrManager = mock(GithubPullRequestManager.class); GithubDiffManager mockDiffManager = mock(GithubDiffManager.class); List<CommitFile> result = new Gson() .fromJson(new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("github_diff.diff"))) , new TypeToken<List<CommitFile>>() {}.getType()); doReturn(result).when(mockDiffManager).getFiles(); doReturn(mockDiffManager).when(mockPrManager).diffManager(); log.debug("original {}", result); GithubDiffReader githubDiffParser = new GithubDiffReader(mockPrManager); List<Diff> parsedResult = githubDiffParser.parse().collect(Collectors.toList()); log.debug("parsed result {}", parsedResult); assertEquals(result.size(), parsedResult.size()); }
Example #3
Source File: GitHubIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testGitHubComponent() throws Exception { String oauthKey = System.getenv("CAMEL_GITHUB_OAUTH_KEY"); Assume.assumeNotNull("CAMEL_GITHUB_OAUTH_KEY not null", oauthKey); CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .toF("github:GETCOMMITFILE?oauthToken=%s&repoOwner=%s&repoName=%s", oauthKey, GITHUB_REPO_OWNER, GITHUB_REPO_NAME); } }); camelctx.start(); try { CommitFile commitFile = new CommitFile(); commitFile.setSha("29222e8ccbb39c3570aa1cd29388e737a930a88d"); ProducerTemplate template = camelctx.createProducerTemplate(); String result = template.requestBody("direct:start", commitFile, String.class); Assert.assertEquals("Hello Kermit", result.trim()); } finally { camelctx.close(); } }
Example #4
Source File: GithubResource.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Path("/get") @GET @Produces(MediaType.TEXT_PLAIN) public String getCamelQuarkusReadme() throws Exception { CommitFile commitFile = new CommitFile(); commitFile.setSha("6195efafd0a8100795247e35942b5c61fea79267"); return producerTemplate.requestBody( "github:GETCOMMITFILE?repoOwner=apache&repoName=camel-quarkus", commitFile, String.class); }
Example #5
Source File: GithubDiffManagerTest.java From cover-checker with Apache License 2.0 | 5 votes |
@Test public void getFileDiff() throws IOException { RepositoryId repoId = new RepositoryId("test", "test"); GithubDiffManager githubDiffManager = new GithubDiffManager(mockPrService, repoId, 1); List<CommitFile> result = new Gson() .fromJson(new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("github_diff.diff"))) , new TypeToken<List<CommitFile>>() {}.getType()); when(mockPrService.getFiles(repoId, 1)).thenReturn(result); assertEquals(result, githubDiffManager.getFiles()); }
Example #6
Source File: GithubDiffManager.java From cover-checker with Apache License 2.0 | 4 votes |
public List<CommitFile> getFiles() throws IOException { log.info("get diff {}/{}", repoId.generateId(), prNumber); return prService.getFiles(repoId, prNumber); }