diff --git a/go.mod b/go.mod index f4ef7989f..e638459fa 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.10.1-0.20240413172830-d0be07ea6b9c github.com/cli/go-gh/v2 v2.10.0 - github.com/cli/oauth v1.0.1 + github.com/cli/oauth v1.1.1 github.com/cli/safeexec v1.0.1 github.com/cpuguy83/go-md2man/v2 v2.0.5 github.com/creack/pty v1.1.23 @@ -159,7 +159,7 @@ require ( golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect golang.org/x/mod v0.20.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.25.0 // indirect + golang.org/x/sys v0.26.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 4f5689856..d1a85b60e 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,8 @@ github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= github.com/cli/go-gh/v2 v2.10.0 h1:GMflBKoErBXlLvN2euxzL+p7JaM8erlSmw0cT7uZr7M= github.com/cli/go-gh/v2 v2.10.0/go.mod h1:MeRoKzXff3ygHu7zP+NVTT+imcHW6p3tpuxHAzRM2xE= -github.com/cli/oauth v1.0.1 h1:pXnTFl/qUegXHK531Dv0LNjW4mLx626eS42gnzfXJPA= -github.com/cli/oauth v1.0.1/go.mod h1:qd/FX8ZBD6n1sVNQO3aIdRxeu5LGw9WhKnYhIIoC2A4= +github.com/cli/oauth v1.1.1 h1:459gD3hSjlKX9B1uXBuiAMdpXBUQ9QGf/NDcCpoQxPs= +github.com/cli/oauth v1.1.1/go.mod h1:qd/FX8ZBD6n1sVNQO3aIdRxeu5LGw9WhKnYhIIoC2A4= github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q= github.com/cli/safeexec v1.0.1 h1:e/C79PbXF4yYTN/wauC4tviMxEV13BwljGj0N9j+N00= github.com/cli/safeexec v1.0.1/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q= @@ -515,8 +515,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= diff --git a/internal/authflow/flow.go b/internal/authflow/flow.go index 3fc753b44..52b00284b 100644 --- a/internal/authflow/flow.go +++ b/internal/authflow/flow.go @@ -48,8 +48,13 @@ func AuthFlow(oauthHost string, IO *iostreams.IOStreams, notice string, addition callbackURI = "http://localhost/" } + host, err := oauth.NewGitHubHost(ghinstance.HostPrefix(oauthHost)) + if err != nil { + return "", "", err + } + flow := &oauth.Flow{ - Host: oauth.GitHubHost(ghinstance.HostPrefix(oauthHost)), + Host: host, ClientID: oauthClientID, ClientSecret: oauthClientSecret, CallbackURI: callbackURI, diff --git a/pkg/cmd/root/help_topic.go b/pkg/cmd/root/help_topic.go index 3da5bf476..e76dd2271 100644 --- a/pkg/cmd/root/help_topic.go +++ b/pkg/cmd/root/help_topic.go @@ -99,6 +99,10 @@ var HelpTopics = []helpTopic{ %[1]sGH_PATH%[1]s: set the path to the gh executable, useful for when gh can not properly determine its own path such as in the cygwin terminal. + + %[1]sGH_MDWIDTH%[1]s: default maximum width for markdown render wrapping. The max width of lines + wrapped on the terminal will be taken as the lesser of the terminal width, this value, or 120 if + not specified. This value is used, for example, with %[1]spr view%[1]s subcommand. `, "`"), }, { diff --git a/pkg/markdown/markdown.go b/pkg/markdown/markdown.go index f3f4951af..63bd9233e 100644 --- a/pkg/markdown/markdown.go +++ b/pkg/markdown/markdown.go @@ -1,6 +1,9 @@ package markdown import ( + "os" + "strconv" + "github.com/charmbracelet/glamour" ghMarkdown "github.com/cli/go-gh/v2/pkg/markdown" ) @@ -10,11 +13,16 @@ func WithoutIndentation() glamour.TermRendererOption { } // WithWrap is a rendering option that set the character limit for soft -// wrapping the markdown rendering. There is a max limit of 120 characters. +// wrapping the markdown rendering. There is a max limit of 120 characters, +// unless the user overrides with an environment variable. // If 0 is passed then wrapping is disabled. func WithWrap(w int) glamour.TermRendererOption { - if w > 120 { - w = 120 + width, err := strconv.Atoi(os.Getenv("GH_MDWIDTH")) + if err != nil { + width = 120 + } + if w > width { + w = width } return ghMarkdown.WithWrap(w) }