From a6770fb1aa267969f12818b21fe81466c1581864 Mon Sep 17 00:00:00 2001 From: Michael Kelly Date: Tue, 3 Dec 2024 13:48:44 -0800 Subject: [PATCH] Minor fixes to rpmtree command (1) The error checking at the beginning isn't necessary because we also want to support WORKSPACE mode. (2) If we pass the default configname through to AddTree() then we'll generate the WORKSPACE file as if we had a lock file, which is not what we desire --- cmd/rpmtree.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/rpmtree.go b/cmd/rpmtree.go index 40583cd..80f676a 100644 --- a/cmd/rpmtree.go +++ b/cmd/rpmtree.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "fmt" "os" "github.com/bazelbuild/buildtools/build" @@ -137,10 +137,6 @@ func NewRpmTreeCmd() *cobra.Command { Short: "Writes a rpmtree rule and its rpmdependencies to bazel files", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, required []string) error { - if rpmtreeopts.toMacro != "" && rpmtreeopts.lockfile != "" { - return errors.New("Must provide at most one of --lockfile --to-macro") - } - repos, err := repo.LoadRepoFiles(rpmtreeopts.repofiles) if err != nil { return err @@ -173,9 +169,12 @@ func NewRpmTreeCmd() *cobra.Command { } var handler Handler + var configname string + if rpmtreeopts.toMacro != "" { handler, err = NewMacroHandler(rpmtreeopts.toMacro) } else if rpmtreeopts.lockfile != "" { + configname = rpmtreeopts.configname handler, err = NewLockFileHandler( rpmtreeopts.configname, rpmtreeopts.lockfile, @@ -198,7 +197,7 @@ func NewRpmTreeCmd() *cobra.Command { return err } - bazel.AddTree(rpmtreeopts.name, rpmtreeopts.configname, build, install, rpmtreeopts.arch, rpmtreeopts.public) + bazel.AddTree(rpmtreeopts.name, configname, build, install, rpmtreeopts.arch, rpmtreeopts.public) handler.PruneRPMs(build) logrus.Info("Writing bazel files.")