mirror of
https://github.com/enso-org/enso.git
synced 2024-12-19 21:21:44 +03:00
Avoid storing 0.0.0-dev into package.yaml (#11805)
Storing `0.0.0-dev` into `package.yaml` makes little sense: - no two _development version_ are the same - there is no way to _download_ `0.0.0-dev` version via `ensoup` - regular releases refuse to process `0.0.0-dev` projects Better to avoid storing such _development version_ at all.
This commit is contained in:
parent
a666ef0abe
commit
3e23e72bed
@ -970,7 +970,8 @@ lazy val pkg = (project in file("lib/scala/pkg"))
|
||||
(`editions` / Compile / exportedModule).value,
|
||||
(`semver` / Compile / exportedModule).value,
|
||||
(`scala-yaml` / Compile / exportedModule).value,
|
||||
(`scala-libs-wrapper` / Compile / exportedModule).value
|
||||
(`scala-libs-wrapper` / Compile / exportedModule).value,
|
||||
(`version-output` / Compile / exportedModule).value
|
||||
)
|
||||
)
|
||||
.dependsOn(editions)
|
||||
|
@ -3,6 +3,7 @@ module org.enso.pkg {
|
||||
requires org.apache.commons.compress;
|
||||
requires org.enso.editions;
|
||||
requires org.enso.semver;
|
||||
requires org.enso.version.output;
|
||||
requires org.enso.scala.yaml;
|
||||
// For io.circe
|
||||
requires org.enso.scala.wrapper;
|
||||
|
@ -5,6 +5,7 @@ import org.enso.semver.SemVer
|
||||
import org.enso.editions.{EditionName, Editions}
|
||||
import org.enso.pkg.validation.NameValidation
|
||||
import org.enso.scala.yaml.{YamlDecoder, YamlEncoder}
|
||||
import org.enso.version.BuildVersion
|
||||
import org.yaml.snakeyaml.{DumperOptions, Yaml}
|
||||
import org.yaml.snakeyaml.error.YAMLException
|
||||
import org.yaml.snakeyaml.nodes.{MappingNode, Node}
|
||||
@ -114,7 +115,19 @@ case class Config(
|
||||
|
||||
/** Converts the configuration into a YAML representation. */
|
||||
def toYaml: String = {
|
||||
val node = implicitly[YamlEncoder[Config]].encode(this)
|
||||
val config: Config = this
|
||||
val noDevEdition: Config =
|
||||
if (
|
||||
config.edition.exists(
|
||||
_.parent
|
||||
.exists(p => p.toString == BuildVersion.defaultDevEnsoVersion())
|
||||
)
|
||||
) {
|
||||
config.copy(edition = None)
|
||||
} else {
|
||||
config
|
||||
}
|
||||
val node = implicitly[YamlEncoder[Config]].encode(noDevEdition)
|
||||
val dumperOptions = new DumperOptions()
|
||||
dumperOptions.setIndent(2)
|
||||
dumperOptions.setPrettyFlow(true)
|
||||
|
@ -46,6 +46,26 @@ class ConfigSpec
|
||||
parsed.edition shouldBe empty
|
||||
}
|
||||
|
||||
"persist normal edition" in {
|
||||
val parsed = Config.fromYaml("name: fooBar\nedition: 2024.4.2").get
|
||||
parsed.name shouldEqual "fooBar"
|
||||
parsed.normalizedName shouldEqual None
|
||||
parsed.moduleName shouldEqual "FooBar"
|
||||
|
||||
val ser = parsed.toYaml
|
||||
ser shouldEqual "name: fooBar\nnamespace: local\nedition: 2024.4.2\n"
|
||||
}
|
||||
|
||||
"don't persist dev edition" in {
|
||||
val parsed = Config.fromYaml("name: fooBar\nedition: 0.0.0-dev").get
|
||||
parsed.name shouldEqual "fooBar"
|
||||
parsed.normalizedName shouldEqual None
|
||||
parsed.moduleName shouldEqual "FooBar"
|
||||
|
||||
val ser = parsed.toYaml
|
||||
ser shouldEqual "name: fooBar\nnamespace: local\n"
|
||||
}
|
||||
|
||||
"correctly de-serialize and serialize back the shortened edition syntax " +
|
||||
"if there are no overrides" in {
|
||||
val config =
|
||||
|
Loading…
Reference in New Issue
Block a user