Merge pull request #8454 from calm329/fix/parse-key-spec-flaky-8326

This commit is contained in:
eugene yokota 2026-01-09 01:27:18 -05:00 committed by GitHub
commit 66aebdb96b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 4 deletions

View File

@ -74,7 +74,11 @@ object ParseKeySpec extends Properties {
def noProject(skm: StructureKeyMask) = {
import skm.{ structure, key }
val mask = skm.mask.copy(project = false)
// When task is shown and task name matches a project name, we need to show config
// to disambiguate (otherwise 'taskName / keyName' could be parsed as 'projectName / keyName')
val taskMatchesProject = hasAmbiguousTaskLabel(key, structure)
val needShowConfig = taskMatchesProject && skm.mask.task && !skm.mask.config
val mask = skm.mask.copy(project = false, config = skm.mask.config || needShowConfig)
// skip when config axis is set to Zero
val hasZeroConfig = key.scope.config ==== Zero
val showZeroConfig = hasAmbiguousLowercaseAxes(key, structure)
@ -187,12 +191,27 @@ object ParseKeySpec extends Properties {
// then a scoped key like `foo/<conf>/foo/name` would render as `foo/name`
// which would be interpreted as `foo/Zero/Zero/name`
// so we mitigate this by explicitly displaying the configuration axis set to Zero
//
// similarly, if a task and a project share the same name (e.g. "zv")
// then a scoped key like `<proj>/<conf>/zv/name` would render as `zv/name`
// which would be interpreted as `zv/Zero/Zero/name` (project zv)
// so we also check if the task label matches a project name
def hasAmbiguousLowercaseAxes(key: ScopedKey[?], structure: Structure): Boolean = {
val label = key.key.label
val allProjects = for {
val allProjects = allProjectNames(structure)
allProjects(label) || hasAmbiguousTaskLabel(key, structure)
}
// checks if the task label matches a project name
def hasAmbiguousTaskLabel(key: ScopedKey[?], structure: Structure): Boolean = {
val taskLabel = key.scope.task.toOption.map(_.label)
val allProjects = allProjectNames(structure)
taskLabel.exists(allProjects)
}
private def allProjectNames(structure: Structure): Set[String] =
for {
uri <- structure.keyIndex.buildURIs
project <- structure.keyIndex.projects(uri)
} yield project
allProjects(label)
}
}