-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvement: adds details to github issue
- Loading branch information
1 parent
6952110
commit c066cc7
Showing
4 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
metals/src/main/scala/scala/meta/internal/metals/GithubNewIssueUrlCreator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package scala.meta.internal.metals | ||
|
||
import java.net.URLEncoder | ||
|
||
import scala.util.Properties | ||
|
||
import scala.meta.internal.bsp.BspResolvedResult | ||
import scala.meta.internal.bsp.BspSession | ||
import scala.meta.internal.bsp.ResolvedBloop | ||
import scala.meta.internal.bsp.ResolvedBspOne | ||
import scala.meta.internal.builds.BuildTools | ||
|
||
import org.eclipse.lsp4j.ClientInfo | ||
|
||
class GithubNewIssueUrlCreator( | ||
tables: Tables, | ||
buildTargets: BuildTargets, | ||
currentBuildServer: () => Option[BspSession], | ||
calculateNewBuildServer: () => BspResolvedResult, | ||
clientInfo: ClientInfo, | ||
buildTools: BuildTools, | ||
) { | ||
|
||
def buildUrl(): String = { | ||
val scalaVersions = | ||
buildTargets.allScala.map(_.scalaVersion).toSet.mkString("; ") | ||
val clientVersion = | ||
Option(clientInfo.getVersion()).map(v => s" v$v").getOrElse("") | ||
val body = | ||
s"""|<!-- | ||
| Describe the bug ... | ||
| | ||
| Reproduction steps | ||
| 1. Go to ... | ||
| 2. Click on ... | ||
| 3. Scroll down to ... | ||
| 4. See error | ||
|--> | ||
| | ||
|### Expected behaviour: | ||
| | ||
|<!-- A clear and concise description of what you expected to happen. --> | ||
| | ||
|**Operating system:** | ||
|${Properties.osName} | ||
| | ||
|**Java version:** | ||
|${Properties.javaVersion} | ||
| | ||
|**Editor/extension:** | ||
|${clientInfo.getName()}$clientVersion | ||
| | ||
|**Metals version:** | ||
|${BuildInfo.metalsVersion} | ||
| | ||
|### Extra context or search terms: | ||
|<!-- | ||
| - Any other context about the problem | ||
| - Search terms to help others discover this | ||
|--> | ||
| | ||
|### Workspace information: | ||
| | ||
| - **Scala versions:** $scalaVersions$selectedBuildTool$selectedBuildServer | ||
| - **All build tools in workspace:** ${buildTools.all.mkString("; ")} | ||
|""".stripMargin | ||
s"https://github.com/scalameta/metals/issues/new?body=${URLEncoder.encode(body)}" | ||
} | ||
|
||
private def selectedBuildTool(): String = { | ||
tables.buildTool | ||
.selectedBuildTool() | ||
.map { value => | ||
s"""| | ||
| - **Build tool:** ${value}""".stripMargin | ||
} | ||
.getOrElse("") | ||
} | ||
|
||
private def selectedBuildServer(): String = { | ||
currentBuildServer() | ||
.map(s => s"${s.main.name} v${s.main.version}") | ||
.orElse { | ||
calculateNewBuildServer() match { | ||
case ResolvedBloop => Some("Bloop") | ||
case ResolvedBspOne(details) => Some(details.getName()) | ||
case _ => None | ||
} | ||
} | ||
.map { s => | ||
s"""| | ||
| - **Build server:** $s""".stripMargin | ||
} | ||
.getOrElse("") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters