feat: support single package repository
All checks were successful
Pre-commit / pre-commit (pull_request) Successful in 7m49s
Update alr-git / changelog (push) Successful in 31s

This commit is contained in:
2025-06-14 22:26:33 +03:00
parent 1ca7801fba
commit d1fe02fa57
4 changed files with 143 additions and 42 deletions

View File

@ -18,6 +18,7 @@ package build
import (
"context"
"os"
"path/filepath"
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/alrsh"
@ -40,10 +41,21 @@ func (s *ScriptResolver) ResolveScript(
repodir := s.cfg.GetPaths().RepoDir
repository = pkg.Repository
if pkg.BasePkgName != "" {
script = filepath.Join(repodir, repository, pkg.BasePkgName, "alr.sh")
// First, we check if there is a root alr.sh in the repository
rootScriptPath := filepath.Join(repodir, repository, "alr.sh")
if _, err := os.Stat(rootScriptPath); err == nil {
// A repository with a single alr.sh at the root
script = rootScriptPath
} else {
script = filepath.Join(repodir, repository, pkg.Name, "alr.sh")
// Multi-package repository - we are looking for alr.sh in the subfolder
var scriptPath string
if pkg.BasePkgName != "" {
scriptPath = filepath.Join(repodir, repository, pkg.BasePkgName, "alr.sh")
} else {
scriptPath = filepath.Join(repodir, repository, pkg.Name, "alr.sh")
}
script = scriptPath
}
return &ScriptInfo{