From e2cc0e10068e6d55253bb7fada7dccd91dc0d00c Mon Sep 17 00:00:00 2001 From: daveberrys <84567826+daveberrys@users.noreply.github.com> Date: Wed, 15 Jul 2026 20:19:14 +0800 Subject: [PATCH] implement pr and issues browse --- src/cmd/browse/issues.go | 20 ++++++++++++++++++++ src/cmd/browse/pr.go | 20 ++++++++++++++++++++ src/cmd/browse/root.go | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 src/cmd/browse/issues.go create mode 100644 src/cmd/browse/pr.go diff --git a/src/cmd/browse/issues.go b/src/cmd/browse/issues.go new file mode 100644 index 0000000..209a7ca --- /dev/null +++ b/src/cmd/browse/issues.go @@ -0,0 +1,20 @@ +package browse + +import ( + "strings" + + "github.com/daveberrys/guh/src/utils" + "github.com/spf13/cobra" + "github.com/pkg/browser" +) + +var issuesCmd = &cobra.Command{ + Use: "issues", + Short: "Opens a browser to the issues page.", + RunE: func(cmd *cobra.Command, args []string) error { + url, err := utils.RunGit(true, "remote", "get-url", "origin") + if err != nil { return err } + url = strings.TrimSuffix(url, ".git") + return browser.OpenURL(url + "/issues") + }, +} diff --git a/src/cmd/browse/pr.go b/src/cmd/browse/pr.go new file mode 100644 index 0000000..3df1ec8 --- /dev/null +++ b/src/cmd/browse/pr.go @@ -0,0 +1,20 @@ +package browse + +import ( + "strings" + + "github.com/daveberrys/guh/src/utils" + "github.com/spf13/cobra" + "github.com/pkg/browser" +) + +var prCmd = &cobra.Command{ + Use: "pr", + Short: "Opens a browser to the PRs page.", + RunE: func(cmd *cobra.Command, args []string) error { + url, err := utils.RunGit(true, "remote", "get-url", "origin") + if err != nil { return err } + url = strings.TrimSuffix(url, ".git") + return browser.OpenURL(url + "/pulls") + }, +} diff --git a/src/cmd/browse/root.go b/src/cmd/browse/root.go index 034cc26..57e3433 100644 --- a/src/cmd/browse/root.go +++ b/src/cmd/browse/root.go @@ -11,6 +11,8 @@ import ( func init() { cmd.RootCmd.AddCommand(createCmd) + createCmd.AddCommand(prCmd) + createCmd.AddCommand(issuesCmd) } var createCmd = &cobra.Command{