|
| 1 | +/* |
| 2 | + * This file is part of sbt-jacoco. |
| 3 | + * |
| 4 | + * Copyright (c) Joachim Hofer & contributors |
| 5 | + * All rights reserved. |
| 6 | + * |
| 7 | + * This program and the accompanying materials |
| 8 | + * are made available under the terms of the Eclipse Public License v1.0 |
| 9 | + * which accompanies this distribution, and is available at |
| 10 | + * http://www.eclipse.org/legal/epl-v10.html |
| 11 | + */ |
| 12 | + |
1 | 13 | package com.github.sbt.jacoco.coveralls
|
2 | 14 |
|
3 | 15 | import java.io.File
|
@@ -29,24 +41,7 @@ class CoverallsReportVisitor(
|
29 | 41 | private val jsonFactory = new JsonFactory()
|
30 | 42 | private val json = jsonFactory.createGenerator(output, JsonEncoding.UTF8)
|
31 | 43 |
|
32 |
| - json.writeStartObject() |
33 |
| - |
34 |
| - repoToken foreach { token => |
35 |
| - json.writeStringField("repo_token", token) |
36 |
| - } |
37 |
| - |
38 |
| - json.writeStringField("service_name", serviceName) |
39 |
| - jobId foreach { id => |
40 |
| - json.writeStringField("service_job_id", id) |
41 |
| - } |
42 |
| - pullRequest foreach { pr => |
43 |
| - json.writeStringField("service_pull_request", pr) |
44 |
| - } |
45 |
| - buildNumber foreach { build => |
46 |
| - json.writeStringField("service_number", build) |
47 |
| - } |
48 |
| - |
49 |
| - json.writeArrayFieldStart("source_files") |
| 44 | + writeBasicInfo() |
50 | 45 |
|
51 | 46 | override def visitInfo(sessionInfos: ju.List[SessionInfo], executionData: ju.Collection[ExecutionData]): Unit = {}
|
52 | 47 |
|
@@ -99,4 +94,55 @@ class CoverallsReportVisitor(
|
99 | 94 | // TODO make common with source file locator
|
100 | 95 | sourceDirs.map(d => d / packageName / fileName).find(_.exists())
|
101 | 96 | }
|
| 97 | + |
| 98 | + private def writeBasicInfo(): Unit = { |
| 99 | + json.writeStartObject() |
| 100 | + |
| 101 | + repoToken foreach { token => |
| 102 | + json.writeStringField("repo_token", token) |
| 103 | + } |
| 104 | + |
| 105 | + json.writeStringField("service_name", serviceName) |
| 106 | + jobId foreach { id => |
| 107 | + json.writeStringField("service_job_id", id) |
| 108 | + } |
| 109 | + pullRequest foreach { pr => |
| 110 | + json.writeStringField("service_pull_request", pr) |
| 111 | + } |
| 112 | + buildNumber foreach { build => |
| 113 | + json.writeStringField("service_number", build) |
| 114 | + } |
| 115 | + |
| 116 | + writeGitInfo() |
| 117 | + |
| 118 | + json.writeArrayFieldStart("source_files") |
| 119 | + } |
| 120 | + |
| 121 | + private def writeGitInfo(): Unit = { |
| 122 | + GitInfo(projectRootDir) foreach { info => |
| 123 | + json.writeObjectFieldStart("git") |
| 124 | + |
| 125 | + json.writeStringField("branch", info.branch) |
| 126 | + |
| 127 | + json.writeObjectFieldStart("head") |
| 128 | + json.writeStringField("id", info.hash) |
| 129 | + json.writeStringField("author_name", info.authorName) |
| 130 | + json.writeStringField("author_email", info.authorEmail) |
| 131 | + json.writeStringField("committer_name", info.committerName) |
| 132 | + json.writeStringField("committer_email", info.committerEmail) |
| 133 | + json.writeStringField("message", info.message) |
| 134 | + json.writeEndObject() |
| 135 | + |
| 136 | + json.writeArrayFieldStart("remotes") |
| 137 | + info.remotes foreach { remote => |
| 138 | + json.writeStartObject() |
| 139 | + json.writeStringField("name", remote.name) |
| 140 | + json.writeStringField("url", remote.url) |
| 141 | + json.writeEndObject() |
| 142 | + } |
| 143 | + json.writeEndArray() |
| 144 | + |
| 145 | + json.writeEndObject() |
| 146 | + } |
| 147 | + } |
102 | 148 | }
|
0 commit comments