@@ -17,7 +17,7 @@ object GoParser extends CoverageParser {
1717
1818 final val MODE = """ mode: ([set|count|atomic]*)""" .r
1919
20- // filename.go:lineFrom.column,lineTo.column numberOfStatements countOfStatements
20+ // filename.go:lineFrom.column,lineTo.column numberOfStatements countOfStatements
2121 final val regexpString = """ ([a-zA-Z\/\._\-\d]*):(\d+).*?,(\d+).* (\d+) (\d+)""" .r
2222
2323 override def parse (rootProject : File , reportFile : File ): Either [String , CoverageReport ] = {
@@ -40,24 +40,29 @@ object GoParser extends CoverageParser {
4040 coverageInfoGroupedByFilename.foldLeft[Seq [CoverageFileReport ]](Seq .empty[CoverageFileReport ])((accum, next) => {
4141 next match {
4242 case (filename, coverageInfosForFile) =>
43- // calculate hits for a file for given statement reports
43+ // Only for Github - Process filename to remove "github.com/orgname/repositoryname/"
44+ val processedFilename = if (filename.startsWith(" github.com/" )) {
45+ filename.split(" /" , 4 ).lastOption.getOrElse(filename) // Get everything after repository name
46+ } else {
47+ filename
48+ }
49+
50+ // Calculate hits for a file for given statement reports
4451 val coverage = coverageInfosForFile.foldLeft(Map [Int , Int ]()) {
4552 case (hitMapAcc, coverageInfo) =>
46- // calculate the range of lines the statement has
53+ // Calculate the range of lines the statement has
4754 val lines = Range .inclusive(coverageInfo.lineFrom, coverageInfo.lineTo)
4855
49- // for each line add the number of hits
56+ // For each line, add the number of hits
5057 hitMapAcc ++ lines.foldLeft(Map [Int , Int ]()) {
5158 case (statementHitMapAcc, line) =>
5259 statementHitMapAcc ++
53- // if the line is already present on the hit map, don't replace the value
60+ // If the line is already present on the hit map, don't replace the value
5461 Map (line -> (hitMapAcc.getOrElse(line, 0 ) + coverageInfo.countOfStatements))
55-
5662 }
5763 }
5864
59- accum :+ CoverageFileReport (filename, coverage)
60-
65+ accum :+ CoverageFileReport (processedFilename, coverage)
6166 }
6267 })
6368
@@ -70,5 +75,4 @@ object GoParser extends CoverageParser {
7075 GoCoverageInfo (filename, lineFrom.toInt, lineTo.toInt, numberOfStatements.toInt, countOfStatements.toInt)
7176 }
7277 }
73-
7478}
0 commit comments