Skip to content

Commit

Permalink
commands: consult global color.ui setting when --color=auto
Browse files Browse the repository at this point in the history
This makes the behavior consistent with other git commands.
  • Loading branch information
mariusae committed Dec 2, 2019
1 parent ec93940 commit 225d74a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
8 changes: 5 additions & 3 deletions commands/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ var cmdApi = &Command{
this can be avoided is by enabling ''--obey-ratelimit''.
--color[=<WHEN>]
Enable colored output even if stdout is not a terminal. <WHEN> can be one
of "always" (default for ''--color''), "never", or "auto" (default).
Enable colored output even if stdout is not a terminal. <WHEN> can
be one of "always", "never", or "auto" (default). If the global
setting "color.ui" is set to "false", then color output is disabled
when the value of ''--color'' is "auto".
--cache <TTL>
Cache valid responses to GET requests for <TTL> seconds.
Expand All @@ -97,7 +99,7 @@ var cmdApi = &Command{
<ENDPOINT>
The GitHub API endpoint to send the HTTP request to (default: "/").
To learn about available endpoints, see <https://developer.github.com/v3/>.
To make GraphQL queries, use "graphql" as <ENDPOINT> and pass ''-F query=QUERY''.
Expand Down
6 changes: 4 additions & 2 deletions commands/ci_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ var cmdCiStatus = &Command{
%t: name of the status check
--color[=<WHEN>]
Enable colored output even if stdout is not a terminal. <WHEN> can be one
of "always" (default for ''--color''), "never", or "auto" (default).
Enable colored output even if stdout is not a terminal. <WHEN> can
be one of "always", "never", or "auto" (default). If the global
setting "color.ui" is set to "false", then color output is disabled
when the value of ''--color'' is "auto".
<COMMIT>
A commit SHA or branch name (default: "HEAD").
Expand Down
9 changes: 7 additions & 2 deletions commands/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ With no arguments, show a list of open issues.
%%: a literal %
--color[=<WHEN>]
Enable colored output even if stdout is not a terminal. <WHEN> can be one
of "always" (default for ''--color''), "never", or "auto" (default).
Enable colored output even if stdout is not a terminal. <WHEN> can
be one of "always", "never", or "auto" (default). If the global
setting "color.ui" is set to "false", then color output is disabled
when the value of ''--color'' is "auto".
-m, --message <MESSAGE>
The text up to the first blank line in <MESSAGE> is treated as the issue
Expand Down Expand Up @@ -634,6 +636,9 @@ func listLabels(cmd *Command, args *Args) {

func colorizeOutput(colorSet bool, when string) bool {
if !colorSet || when == "auto" {
if value, _ := git.GlobalConfig("color.ui"); value == "false" {
return false
}
return ui.IsTerminal(os.Stdout)
} else if when == "never" {
return false
Expand Down
6 changes: 4 additions & 2 deletions commands/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ pr show [-uc] [-f <FORMAT>] <PR-NUMBER>
%%: a literal %
--color[=<WHEN>]
Enable colored output even if stdout is not a terminal. <WHEN> can be one
of "always" (default for ''--color''), "never", or "auto" (default).
Enable colored output even if stdout is not a terminal. <WHEN> can
be one of "always", "never", or "auto" (default). If the global
setting "color.ui" is set to "false", then color output is disabled
when the value of ''--color'' is "auto".
-o, --sort <KEY>
Sort displayed pull requests by "created" (default), "updated", "popularity", or "long-running".
Expand Down
8 changes: 5 additions & 3 deletions commands/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ With no arguments, shows a list of existing releases.
-t, --commitish <TARGET>
A commit SHA or branch name to attach the release to, only used if <TAG>
does not already exist (default: main branch).
-i, --include <PATTERN>
Filter the files in the release to those that match the glob <PATTERN>.
Expand Down Expand Up @@ -153,8 +153,10 @@ With no arguments, shows a list of existing releases.
%%: a literal %
--color[=<WHEN>]
Enable colored output even if stdout is not a terminal. <WHEN> can be one
of "always" (default for ''--color''), "never", or "auto" (default).
Enable colored output even if stdout is not a terminal. <WHEN> can
be one of "always", "never", or "auto" (default). If the global
setting "color.ui" is set to "false", then color output is disabled
when the value of ''--color'' is "auto".
<TAG>
The git tag name for this release.
Expand Down
6 changes: 4 additions & 2 deletions commands/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ same-named branch on the remote, treat that as its upstream branch.
## Options:
--color[=<WHEN>]
Enable colored output even if stdout is not a terminal. <WHEN> can be one
of "always" (default for ''--color''), "never", or "auto" (default).
Enable colored output even if stdout is not a terminal. <WHEN> can
be one of "always", "never", or "auto" (default). If the global
setting "color.ui" is set to "false", then color output is disabled
when the value of ''--color'' is "auto".
## See also:
Expand Down

0 comments on commit 225d74a

Please sign in to comment.