"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/cmd/browse/browse.go" between
gh-cli-1.12.1.tar.gz and gh-cli-1.13.1.tar.gz

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

browse.go  (gh-cli-1.12.1):browse.go  (gh-cli-1.13.1)
skipping to change at line 29 skipping to change at line 29
} }
type BrowseOptions struct { type BrowseOptions struct {
BaseRepo func() (ghrepo.Interface, error) BaseRepo func() (ghrepo.Interface, error)
Browser browser Browser browser
HttpClient func() (*http.Client, error) HttpClient func() (*http.Client, error)
IO *iostreams.IOStreams IO *iostreams.IOStreams
SelectorArg string SelectorArg string
Branch string Branch string
ProjectsFlag bool ProjectsFlag bool
SettingsFlag bool SettingsFlag bool
WikiFlag bool WikiFlag bool
NoBrowserFlag bool
} }
func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Co mmand { func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Co mmand {
opts := &BrowseOptions{ opts := &BrowseOptions{
Browser: f.Browser, Browser: f.Browser,
HttpClient: f.HttpClient, HttpClient: f.HttpClient,
IO: f.IOStreams, IO: f.IOStreams,
} }
cmd := &cobra.Command{ cmd := &cobra.Command{
skipping to change at line 102 skipping to change at line 103
return runF(opts) return runF(opts)
} }
return runBrowse(opts) return runBrowse(opts)
}, },
} }
cmdutil.EnableRepoOverride(cmd, f) cmdutil.EnableRepoOverride(cmd, f)
cmd.Flags().BoolVarP(&opts.ProjectsFlag, "projects", "p", false, "Open re pository projects") cmd.Flags().BoolVarP(&opts.ProjectsFlag, "projects", "p", false, "Open re pository projects")
cmd.Flags().BoolVarP(&opts.WikiFlag, "wiki", "w", false, "Open repository wiki") cmd.Flags().BoolVarP(&opts.WikiFlag, "wiki", "w", false, "Open repository wiki")
cmd.Flags().BoolVarP(&opts.SettingsFlag, "settings", "s", false, "Open re pository settings") cmd.Flags().BoolVarP(&opts.SettingsFlag, "settings", "s", false, "Open re pository settings")
cmd.Flags().BoolVarP(&opts.NoBrowserFlag, "no-browser", "n", false, "Prin t destination URL instead of opening the browser")
cmd.Flags().StringVarP(&opts.Branch, "branch", "b", "", "Select another b ranch by passing in the branch name") cmd.Flags().StringVarP(&opts.Branch, "branch", "b", "", "Select another b ranch by passing in the branch name")
return cmd return cmd
} }
func runBrowse(opts *BrowseOptions) error { func runBrowse(opts *BrowseOptions) error {
baseRepo, err := opts.BaseRepo() baseRepo, err := opts.BaseRepo()
if err != nil { if err != nil {
return fmt.Errorf("unable to determine base repository: %w", err) return fmt.Errorf("unable to determine base repository: %w", err)
} }
skipping to change at line 154 skipping to change at line 156
branchName, err := api.RepoDefaultBranch(apiClien t, baseRepo) branchName, err := api.RepoDefaultBranch(apiClien t, baseRepo)
if err != nil { if err != nil {
return err return err
} }
url += "/tree/" + branchName + "/" url += "/tree/" + branchName + "/"
} }
url += fileArg url += fileArg
} }
} }
if opts.IO.IsStdoutTTY() { if opts.NoBrowserFlag {
fmt.Fprintf(opts.IO.Out, "now opening %s in browser\n", url) fmt.Fprintf(opts.IO.Out, "%s\n", url)
return nil
} else {
if opts.IO.IsStdoutTTY() {
fmt.Fprintf(opts.IO.Out, "now opening %s in browser\n", u
rl)
}
return opts.Browser.Browse(url)
} }
return opts.Browser.Browse(url)
} }
func parseFileArg(fileArg string) (string, error) { func parseFileArg(fileArg string) (string, error) {
arr := strings.Split(fileArg, ":") arr := strings.Split(fileArg, ":")
if len(arr) > 2 { if len(arr) > 2 {
return "", fmt.Errorf("invalid use of colon\nUse 'gh browse --hel p' for more information about browse\n") return "", fmt.Errorf("invalid use of colon\nUse 'gh browse --hel p' for more information about browse\n")
} }
if len(arr) > 1 { if len(arr) > 1 {
if !isNumber(arr[1]) { if !isNumber(arr[1]) {
return "", fmt.Errorf("invalid line number after colon\nU se 'gh browse --help' for more information about browse\n") return "", fmt.Errorf("invalid line number after colon\nU se 'gh browse --help' for more information about browse\n")
 End of changes. 4 change blocks. 
7 lines changed or deleted 15 lines changed or added

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