Skip to content

Commit c440902

Browse files
authored
Merge pull request #159 from lloydmeta/feature/canonical-relativeSource-src
Resolve canonical path for src in BaseReportWriter.relativeSource
2 parents 8008068 + 0acc293 commit c440902

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.9
1+
sbt.version=0.13.11

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ resolvers += Classpaths.sbtPluginReleases
22

33
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.3.2")
44

5-
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")
5+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
66

77
addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.5")
88

scalac-scoverage-plugin/src/main/scala/scoverage/report/BaseReportWriter.scala

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ class BaseReportWriter(sourceDirectories: Seq[File], outputDir: File, ignoreStat
1818
def relativeSource(src: String): String = relativeSource(src, formattedSourcePaths)
1919

2020
private def relativeSource(src: String, sourcePaths: Seq[String]): String = {
21+
// We need the canonical path for the given src because our formattedSourcePaths are canonical
22+
val canonicalSrc = new File(src).getCanonicalPath
2123
val sourceRoot: Option[String] = sourcePaths.find(
22-
sourcePath => src.startsWith(sourcePath)
24+
sourcePath => canonicalSrc.startsWith(sourcePath)
2325
)
2426
sourceRoot match {
25-
case Some(path: String) => src.replace(path, "")
27+
case Some(path: String) => canonicalSrc.replace(path, "")
2628
case _ =>
2729
val fmtSourcePaths: String = sourcePaths.mkString("'", "', '", "'")
28-
throw new RuntimeException(s"No source root found for '$src' (source roots: $fmtSourcePaths)");
30+
throw new RuntimeException(s"No source root found for '$canonicalSrc' (source roots: $fmtSourcePaths)");
2931
}
3032
}
3133

0 commit comments

Comments
 (0)