From 124ae628888c3db5eec71c71556a6929e151f0f8 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 1 Jan 2025 22:27:33 +0100 Subject: [PATCH] fix: Suppress gitleaks logspam --- go.mod | 2 +- internal/cmd/nozerolog.go | 14 ++++ internal/cmd/testdata/scripts/gitleaks.txtar | 82 ++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 internal/cmd/nozerolog.go create mode 100644 internal/cmd/testdata/scripts/gitleaks.txtar diff --git a/go.mod b/go.mod index e5c59a22439..634df031652 100644 --- a/go.mod +++ b/go.mod @@ -33,6 +33,7 @@ require ( github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a github.com/pelletier/go-toml/v2 v2.2.3 github.com/rogpeppe/go-internal v1.13.1 + github.com/rs/zerolog v1.33.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 @@ -140,7 +141,6 @@ require ( github.com/pjbgf/sha1cd v0.3.1 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/rs/zerolog v1.33.0 // indirect github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect diff --git a/internal/cmd/nozerolog.go b/internal/cmd/nozerolog.go new file mode 100644 index 00000000000..7602d4f3c1a --- /dev/null +++ b/internal/cmd/nozerolog.go @@ -0,0 +1,14 @@ +package cmd + +import ( + "io" + + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" +) + +func init() { + // Suppress log output from github.com/zricethezav/gitleaks/v8. + // See https://github.com/gitleaks/gitleaks/issues/1684. + log.Logger = zerolog.New(io.Discard) +} diff --git a/internal/cmd/testdata/scripts/gitleaks.txtar b/internal/cmd/testdata/scripts/gitleaks.txtar new file mode 100644 index 00000000000..6f40d77826f --- /dev/null +++ b/internal/cmd/testdata/scripts/gitleaks.txtar @@ -0,0 +1,82 @@ +# test that there is no output when adding a complex file +exec chezmoi add $HOME${/}.karabiner.json +! stderr . +! stdout . + +-- home/user/.karabiner.json -- +{ + "profiles": [ + { + "complex_modifications": { + "rules": [ + { + "manipulators": [ + { + "description": "Change caps_lock to command+control+option+shift.", + "from": { + "key_code": "caps_lock", + "modifiers": { "optional": ["any"] } + }, + "to": [ + { + "key_code": "left_shift", + "modifiers": ["left_command", "left_control", "left_option"] + } + ], + "type": "basic" + } + ] + } + ] + }, + "devices": [ + { + "identifiers": { + "is_keyboard": true, + "product_id": 25903, + "vendor_id": 3141 + }, + "manipulate_caps_lock_led": false, + "simple_modifications": [ + { + "from": { "key_code": "left_command" }, + "to": [{ "key_code": "left_option" }] + }, + { + "from": { "key_code": "left_option" }, + "to": [{ "key_code": "left_command" }] + } + ] + } + ], + "fn_function_keys": [ + { + "from": { "key_code": "f3" }, + "to": [{ "key_code": "mission_control" }] + }, + { + "from": { "key_code": "f4" }, + "to": [{ "key_code": "launchpad" }] + }, + { + "from": { "key_code": "f5" }, + "to": [{ "key_code": "illumination_decrement" }] + }, + { + "from": { "key_code": "f6" }, + "to": [{ "key_code": "illumination_increment" }] + }, + { + "from": { "key_code": "f9" }, + "to": [{ "consumer_key_code": "fastforward" }] + } + ], + "name": "Default profile", + "selected": true, + "virtual_hid_keyboard": { + "country_code": 0, + "keyboard_type_v2": "ansi" + } + } + ] +}