@@ -1106,8 +1106,8 @@ object Build {
1106
1106
},
1107
1107
run := {
1108
1108
val log = streams.value.log
1109
+ val projectName = projectInfo.value.nameFormal
1109
1110
val args : Seq [String ] = spaceDelimited(" <arg>" ).parsed
1110
- args.foreach(println)
1111
1111
val rootDir = (ThisBuild / baseDirectory).value
1112
1112
val srcDir = (Compile / scalaSource).value.relativeTo(rootDir).get
1113
1113
val reference = (Compile / sourceManaged).value.relativeTo(rootDir).get / " scala-library-src"
@@ -1135,19 +1135,42 @@ object Build {
1135
1135
IO .copyFile(referenceStdlibPaths, destination)
1136
1136
}
1137
1137
}
1138
+ case " diff" +: rest =>
1139
+ log.info(s " Diffing ${name.value}/src with scala-library sources " )
1140
+ if (rest.size > 1 ) {
1141
+ log.error(s " Too many arguments for $projectName/run diff " )
1142
+ } else {
1143
+ val path = rest.headOption.getOrElse(" " )
1144
+ val fullPath = srcDir / path
1145
+ if (! fullPath.exists) {
1146
+ log.error(s " $fullPath does not exist " )
1147
+ } else {
1148
+ // `--diff-filter=ACMR` is missing `D` on purpose not to show all the files that have not been overwritten.
1149
+ val command = s " git diff --diff-filter=ACMR --no-index --color=always -- $reference/ $path $fullPath"
1150
+ log.info(command)
1151
+ import _root_ .scala .sys .process ._
1152
+ command.!
1153
+ }
1154
+ }
1138
1155
case _ =>
1139
1156
val projectName = projectInfo.value.nameFormal
1140
1157
println(
1141
1158
s """ Usage:
1142
1159
|> $projectName/run list
1143
- | -- lists all files that are not overriden in scala2-library-bootstrapped /src
1160
+ | -- lists all files that are not overriden in ${name.value} /src
1144
1161
|
1145
1162
|> $projectName/run clone <sources>*
1146
- | -- clones the specified sources from the scala2-library-bootstrapped /src
1163
+ | -- clones the specified sources from the ${name.value} /src
1147
1164
| -- example: $projectName/run clone scala/Option.scala
1148
1165
|
1149
1166
|> $projectName/run overwrite <sources>*
1150
- | -- (danger) overwrites the specified sources from the scala2-library-bootstrapped/src
1167
+ | -- (danger) overwrites the specified sources from the ${name.value}/src
1168
+ |
1169
+ |> $projectName/run diff [path]
1170
+ | -- shows the git diff between the reference library sources the sources used to compile $projectName
1171
+ | -- [path] optional path in the library, eg:
1172
+ | -- $projectName/run diff scala/Predef.scala
1173
+ | -- $projectName/run diff scala/collection/immutable
1151
1174
| """ .stripMargin)
1152
1175
}
1153
1176
}
0 commit comments