chore(ax): centralise release workflow input resolution

This commit is contained in:
Virgil 2026-04-01 22:38:13 +00:00
parent 7cf8b504f0
commit e7c991ed36

View file

@ -96,18 +96,7 @@ func ResolveReleaseWorkflowPath(projectDir, outputPath string) string {
// build.ResolveReleaseWorkflowInputPath("/tmp/project", "ci/release.yml", "ci.yml") // error
func ResolveReleaseWorkflowInputPath(projectDir, path, outputPath string) (string, error) {
resolve := func(input string) string {
if input == "" {
return ReleaseWorkflowPath(projectDir)
}
if isWorkflowDirectoryInput(input) {
if ax.IsAbs(input) {
return ax.Join(input, DefaultReleaseWorkflowFileName)
}
return ax.Join(projectDir, input, DefaultReleaseWorkflowFileName)
}
return ResolveReleaseWorkflowPath(projectDir, input)
return resolveReleaseWorkflowInputPath(projectDir, input, nil)
}
if path != "" && outputPath != "" {
@ -137,22 +126,7 @@ func ResolveReleaseWorkflowInputPath(projectDir, path, outputPath string) (strin
// build.ResolveReleaseWorkflowInputPathWithMedium(io.Local, "/tmp/project", "ci", "") // /tmp/project/ci/release.yml when /tmp/project/ci exists
func ResolveReleaseWorkflowInputPathWithMedium(medium io_interface.Medium, projectDir, path, outputPath string) (string, error) {
resolve := func(input string) string {
if input == "" {
return ReleaseWorkflowPath(projectDir)
}
if isWorkflowDirectoryInput(input) {
if ax.IsAbs(input) {
return ax.Join(input, DefaultReleaseWorkflowFileName)
}
return ax.Join(projectDir, input, DefaultReleaseWorkflowFileName)
}
resolved := ResolveReleaseWorkflowPath(projectDir, input)
if medium != nil && medium.IsDir(resolved) {
return ax.Join(resolved, DefaultReleaseWorkflowFileName)
}
return resolved
return resolveReleaseWorkflowInputPath(projectDir, input, medium)
}
if path != "" && outputPath != "" {
@ -175,6 +149,28 @@ func ResolveReleaseWorkflowInputPathWithMedium(medium io_interface.Medium, proje
return resolve(""), nil
}
// resolveReleaseWorkflowInputPath resolves one workflow input into a file path.
//
// resolveReleaseWorkflowInputPath("/tmp/project", "ci", io.Local) // /tmp/project/ci/release.yml
func resolveReleaseWorkflowInputPath(projectDir, input string, medium io_interface.Medium) string {
if input == "" {
return ReleaseWorkflowPath(projectDir)
}
if isWorkflowDirectoryInput(input) {
if ax.IsAbs(input) {
return ax.Join(input, DefaultReleaseWorkflowFileName)
}
return ax.Join(projectDir, input, DefaultReleaseWorkflowFileName)
}
resolved := ResolveReleaseWorkflowPath(projectDir, input)
if medium != nil && medium.IsDir(resolved) {
return ax.Join(resolved, DefaultReleaseWorkflowFileName)
}
return resolved
}
// isWorkflowDirectoryPath reports whether a workflow path is explicitly marked
// as a directory with a trailing separator.
func isWorkflowDirectoryPath(path string) bool {