diff --git a/pkg/cmd/secret/delete/delete.go b/pkg/cmd/secret/delete/delete.go index 84a5e7a83..1cbfbca9d 100644 --- a/pkg/cmd/secret/delete/delete.go +++ b/pkg/cmd/secret/delete/delete.go @@ -3,6 +3,7 @@ package delete import ( "fmt" "net/http" + "os" "github.com/MakeNowJust/heredoc" "github.com/cli/cli/v2/api" @@ -48,8 +49,9 @@ func NewCmdDelete(f *cmdutil.Factory, runF func(*DeleteOptions) error) *cobra.Co RunE: func(cmd *cobra.Command, args []string) error { // If the user specified a repo directly, then we're using the OverrideBaseRepoFunc set by EnableRepoOverride // So there's no reason to use the specialised BaseRepoFunc that requires remote disambiguation. - opts.BaseRepo = f.BaseRepo - if !cmd.Flags().Changed("repo") { + if cmd.Flags().Changed("repo") || os.Getenv("GH_REPO") != "" { + opts.BaseRepo = f.BaseRepo + } else { // If they haven't specified a repo directly, then we will wrap the BaseRepoFunc in one that errors if // there might be multiple valid remotes. opts.BaseRepo = shared.RequireNoAmbiguityBaseRepoFunc(opts.BaseRepo, f.Remotes) diff --git a/pkg/cmd/secret/list/list.go b/pkg/cmd/secret/list/list.go index af3526386..c976bd60e 100644 --- a/pkg/cmd/secret/list/list.go +++ b/pkg/cmd/secret/list/list.go @@ -3,6 +3,7 @@ package list import ( "fmt" "net/http" + "os" "slices" "strings" "time" @@ -69,8 +70,9 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman RunE: func(cmd *cobra.Command, args []string) error { // If the user specified a repo directly, then we're using the OverrideBaseRepoFunc set by EnableRepoOverride // So there's no reason to use the specialised BaseRepoFunc that requires remote disambiguation. - opts.BaseRepo = f.BaseRepo - if !cmd.Flags().Changed("repo") { + if cmd.Flags().Changed("repo") || os.Getenv("GH_REPO") != "" { + opts.BaseRepo = f.BaseRepo + } else { // If they haven't specified a repo directly, then we will wrap the BaseRepoFunc in one that errors if // there might be multiple valid remotes. opts.BaseRepo = shared.RequireNoAmbiguityBaseRepoFunc(opts.BaseRepo, f.Remotes) diff --git a/pkg/cmd/secret/set/set.go b/pkg/cmd/secret/set/set.go index 3c12b4192..89f11f1cf 100644 --- a/pkg/cmd/secret/set/set.go +++ b/pkg/cmd/secret/set/set.go @@ -106,8 +106,9 @@ func NewCmdSet(f *cmdutil.Factory, runF func(*SetOptions) error) *cobra.Command RunE: func(cmd *cobra.Command, args []string) error { // If the user specified a repo directly, then we're using the OverrideBaseRepoFunc set by EnableRepoOverride // So there's no reason to use the specialised BaseRepoFunc that requires remote disambiguation. - opts.BaseRepo = f.BaseRepo - if !cmd.Flags().Changed("repo") { + if cmd.Flags().Changed("repo") || os.Getenv("GH_REPO") != "" { + opts.BaseRepo = f.BaseRepo + } else { // If they haven't specified a repo directly, then we will wrap the BaseRepoFunc in one that errors if // there might be multiple valid remotes. opts.BaseRepo = shared.RequireNoAmbiguityBaseRepoFunc(opts.BaseRepo, f.Remotes)