From fd7f987e581b8e49dcdcdad266db30a29e9fb41d Mon Sep 17 00:00:00 2001 From: Hermann Stanew Date: Thu, 24 Aug 2023 18:30:55 +0200 Subject: [PATCH 01/10] Fix up Nix installation instructions (#7891) --- docs/install_linux.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/install_linux.md b/docs/install_linux.md index 0825c3305..82d3c1a77 100644 --- a/docs/install_linux.md +++ b/docs/install_linux.md @@ -197,10 +197,10 @@ kiss b github-cli && kiss i github-cli ### Nix/NixOS -Nix/NixOS users can install from [nixpkgs](https://search.nixos.org/packages?show=gitAndTools.gh&query=gh&from=0&size=30&sort=relevance&channel=20.03#disabled): +Nix/NixOS users can install from [nixpkgs](https://search.nixos.org/packages?query=gh&sort=relevance&show=gh): ```bash -nix-env -iA nixos.gitAndTools.gh +nix-env -iA nixos.gh ``` ### openSUSE Tumbleweed From 508065b72dff8087d36f039f54cef2708ae4d1d4 Mon Sep 17 00:00:00 2001 From: Jun Nishimura Date: Sat, 26 Aug 2023 01:37:37 +0900 Subject: [PATCH 02/10] Add verbose flag to api cmd (#7826) --- api/http_client.go | 10 ++++- api/http_client_test.go | 83 ++++++++++---------------------------- pkg/cmd/api/api.go | 58 ++++++++++++++++++-------- pkg/cmd/api/api_test.go | 35 ++++++++++++++++ pkg/cmd/factory/default.go | 1 + pkg/cmd/root/root.go | 27 +------------ pkg/cmdutil/factory.go | 23 ++++++----- 7 files changed, 120 insertions(+), 117 deletions(-) diff --git a/api/http_client.go b/api/http_client.go index 53225b139..9f2d59ce3 100644 --- a/api/http_client.go +++ b/api/http_client.go @@ -23,6 +23,7 @@ type HTTPClientOptions struct { EnableCache bool Log io.Writer LogColorize bool + LogVerboseHTTP bool SkipAcceptHeaders bool } @@ -35,10 +36,15 @@ func NewHTTPClient(opts HTTPClientOptions) (*http.Client, error) { LogIgnoreEnv: true, } - if debugEnabled, debugValue := utils.IsDebugEnabled(); debugEnabled { + debugEnabled, debugValue := utils.IsDebugEnabled() + if strings.Contains(debugValue, "api") { + opts.LogVerboseHTTP = true + } + + if opts.LogVerboseHTTP || debugEnabled { clientOpts.Log = opts.Log clientOpts.LogColorize = opts.LogColorize - clientOpts.LogVerboseHTTP = strings.Contains(debugValue, "api") + clientOpts.LogVerboseHTTP = opts.LogVerboseHTTP } headers := map[string]string{ diff --git a/api/http_client_test.go b/api/http_client_test.go index 5bfe0aa05..b1e84e582 100644 --- a/api/http_client_test.go +++ b/api/http_client_test.go @@ -6,7 +6,6 @@ import ( "io" "net/http" "net/http/httptest" - "os" "regexp" "strings" "testing" @@ -19,16 +18,14 @@ import ( func TestNewHTTPClient(t *testing.T) { type args struct { - config tokenGetter - appVersion string - setAccept bool + config tokenGetter + appVersion string + setAccept bool + logVerboseHTTP bool } tests := []struct { name string args args - envDebug string - setGhDebug bool - envGhDebug string host string wantHeader map[string]string wantStderr string @@ -36,9 +33,10 @@ func TestNewHTTPClient(t *testing.T) { { name: "github.com with Accept header", args: args{ - config: tinyConfig{"github.com:oauth_token": "MYTOKEN"}, - appVersion: "v1.2.3", - setAccept: true, + config: tinyConfig{"github.com:oauth_token": "MYTOKEN"}, + appVersion: "v1.2.3", + setAccept: true, + logVerboseHTTP: false, }, host: "github.com", wantHeader: map[string]string{ @@ -51,9 +49,10 @@ func TestNewHTTPClient(t *testing.T) { { name: "github.com no Accept header", args: args{ - config: tinyConfig{"github.com:oauth_token": "MYTOKEN"}, - appVersion: "v1.2.3", - setAccept: false, + config: tinyConfig{"github.com:oauth_token": "MYTOKEN"}, + appVersion: "v1.2.3", + setAccept: false, + logVerboseHTTP: false, }, host: "github.com", wantHeader: map[string]string{ @@ -66,9 +65,10 @@ func TestNewHTTPClient(t *testing.T) { { name: "github.com no authentication token", args: args{ - config: tinyConfig{"example.com:oauth_token": "MYTOKEN"}, - appVersion: "v1.2.3", - setAccept: true, + config: tinyConfig{"example.com:oauth_token": "MYTOKEN"}, + appVersion: "v1.2.3", + setAccept: true, + logVerboseHTTP: false, }, host: "github.com", wantHeader: map[string]string{ @@ -81,45 +81,12 @@ func TestNewHTTPClient(t *testing.T) { { name: "github.com in verbose mode", args: args{ - config: tinyConfig{"github.com:oauth_token": "MYTOKEN"}, - appVersion: "v1.2.3", - setAccept: true, + config: tinyConfig{"github.com:oauth_token": "MYTOKEN"}, + appVersion: "v1.2.3", + setAccept: true, + logVerboseHTTP: true, }, - host: "github.com", - envDebug: "api", - setGhDebug: false, - wantHeader: map[string]string{ - "authorization": "token MYTOKEN", - "user-agent": "GitHub CLI v1.2.3", - "accept": "application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview", - }, - wantStderr: heredoc.Doc(` - * Request at