"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/cmdutil/repo_override.go" between
gh-cli-1.11.0.tar.gz and gh-cli-1.12.0.tar.gz

About: GitHub CLI is GitHub’s official command line tool.

repo_override.go  (gh-cli-1.11.0):repo_override.go  (gh-cli-1.12.0)
package cmdutil package cmdutil
import ( import (
"os" "os"
"github.com/cli/cli/internal/ghrepo" "github.com/cli/cli/internal/ghrepo"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
func executeParentHooks(cmd *cobra.Command, args []string) error {
for cmd.HasParent() {
cmd = cmd.Parent()
if cmd.PersistentPreRunE != nil {
return cmd.PersistentPreRunE(cmd, args)
}
}
return nil
}
func EnableRepoOverride(cmd *cobra.Command, f *Factory) { func EnableRepoOverride(cmd *cobra.Command, f *Factory) {
cmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `[HOST/]OWNER/REPO` format") cmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `[HOST/]OWNER/REPO` format")
cmd.PersistentPreRun = func(cmd *cobra.Command, args []string) { cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
repoOverride, _ := cmd.Flags().GetString("repo") if err := executeParentHooks(cmd, args); err != nil {
if repoFromEnv := os.Getenv("GH_REPO"); repoOverride == "" && rep return err
oFromEnv != "" {
repoOverride = repoFromEnv
} }
if repoOverride != "" { repoOverride, _ := cmd.Flags().GetString("repo")
// NOTE: this mutates the factory f.BaseRepo = OverrideBaseRepoFunc(f, repoOverride)
f.BaseRepo = func() (ghrepo.Interface, error) { return nil
return ghrepo.FromFullName(repoOverride) }
} }
func OverrideBaseRepoFunc(f *Factory, override string) func() (ghrepo.Interface,
error) {
if override == "" {
override = os.Getenv("GH_REPO")
}
if override != "" {
return func() (ghrepo.Interface, error) {
return ghrepo.FromFullName(override)
} }
} }
return f.BaseRepo
} }
 End of changes. 4 change blocks. 
10 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)