From dc851fcf5389a2fd8269f2beb7e900ad4b49632f Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Thu, 30 Jun 2022 06:57:39 +0200 Subject: [PATCH] feat(git): override untracked mode for all repo's resolves #2454 --- src/segments/git.go | 5 +++++ src/segments/git_test.go | 7 +++++++ website/docs/segments/git.mdx | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/segments/git.go b/src/segments/git.go index 5d1b4e9d..2429963e 100644 --- a/src/segments/git.go +++ b/src/segments/git.go @@ -518,6 +518,11 @@ func (g *Git) getOriginURL(upstream string) string { func (g *Git) getUntrackedFilesMode() string { mode := "normal" repoModes := g.props.GetKeyValueMap(UntrackedModes, map[string]string{}) + // make use of a wildcard for all repo's + if val := repoModes["*"]; len(val) != 0 { + mode = val + } + // get the specific repo mode if val := repoModes[g.realFolder]; len(val) != 0 { mode = val } diff --git a/src/segments/git_test.go b/src/segments/git_test.go index 521b89df..c9d10bf4 100644 --- a/src/segments/git_test.go +++ b/src/segments/git_test.go @@ -788,6 +788,13 @@ func TestGitUntrackedMode(t *testing.T) { "bar": "normal", }, }, + { + Case: "Global mode", + Expected: "-uno", + UntrackedModes: map[string]string{ + "*": "no", + }, + }, } for _, tc := range cases { diff --git a/website/docs/segments/git.mdx b/website/docs/segments/git.mdx index 2b438ae6..1a2a6b65 100644 --- a/website/docs/segments/git.mdx +++ b/website/docs/segments/git.mdx @@ -67,7 +67,8 @@ You can set the following properties to `true` to enable fetching additional inf - fetch_worktree_count: `boolean` fetch worktree count - defaults to `false` - fetch_upstream_icon: `boolean` - fetch upstream icon - defaults to `false` - untracked_modes: `map[string]string` - map of repo's where to override the default untracked mode (`no` | `normal` | `all`). For example -`"untracked_modes": { "/Users/me/repos/repo1": "no" }` - defaults to `normal` for all repo's +`"untracked_modes": { "/Users/me/repos/repo1": "no" }` - defaults to `normal` for all repo's. If you want to override for all repo's, use +`*` to set the mode instead of the repo path. ### Icons