Skip to content

Commit

Permalink
feat(migrate): Add path conventions for package configuration files
Browse files Browse the repository at this point in the history
Apply the path conventions from the ort-config repository also to
package configuration files.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Sep 21, 2023
1 parent 62a0e5b commit dd28408
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion plugins/commands/migrate/src/main/kotlin/MigrateCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class MigrateCommand : OrtCommand(
}
}.toMap()

val configsDir = getCommonParentFile(pkgConfigFiles.keys)
candidateFiles -= pkgConfigFiles.keys
echo("Skipping ${candidateFiles.size} files of unknown format.")

Expand Down Expand Up @@ -129,7 +130,18 @@ class MigrateCommand : OrtCommand(
}

if (configWithFixedId != config) {
configYamlMapper.writeValue(file, configWithFixedId)
val oldPath = file.relativeTo(configsDir).path
val newName = if (configWithFixedId.sourceArtifactUrl != null) "source-artifact" else "vcs"
val newPath = "${configWithFixedId.id.toPath(emptyValue = "_")}/$newName.yml"
val newFile = configsDir.resolve(newPath)

// TODO: Maybe make this optional to support layouts that do not follow ort-config conventions.
if (newPath != oldPath) {
configsDir.resolve(oldPath).delete()
newFile.parentFile.safeMkdirs()
}

configYamlMapper.writeValue(newFile, configWithFixedId)
}
}
}
Expand Down

0 comments on commit dd28408

Please sign in to comment.