Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
repo
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test
tools
repo
Commits
42e679b9
Commit
42e679b9
authored
10 years ago
by
Conley Owens
Committed by
Gerrit Code Review
10 years ago
Browse files
Options
Downloads
Plain Diff
Merge "add a global --color option"
parents
c8d882ae
902665bc
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
color.py
+25
-2
25 additions, 2 deletions
color.py
main.py
+6
-0
6 additions, 0 deletions
main.py
with
31 additions
and
2 deletions
color.py
+
25
−
2
View file @
42e679b9
...
...
@@ -83,12 +83,35 @@ def _Color(fg = None, bg = None, attr = None):
return
code
DEFAULT
=
None
def
SetDefaultColoring
(
state
):
"""
Set coloring behavior to |state|.
This is useful for overriding config options via the command line.
"""
if
state
is
None
:
# Leave it alone -- return quick!
return
global
DEFAULT
state
=
state
.
lower
()
if
state
in
(
'
auto
'
,):
DEFAULT
=
state
elif
state
in
(
'
always
'
,
'
yes
'
,
'
true
'
,
True
):
DEFAULT
=
'
always
'
elif
state
in
(
'
never
'
,
'
no
'
,
'
false
'
,
False
):
DEFAULT
=
'
never
'
class
Coloring
(
object
):
def
__init__
(
self
,
config
,
section_type
):
self
.
_section
=
'
color.%s
'
%
section_type
self
.
_config
=
config
self
.
_out
=
sys
.
stdout
on
=
DEFAULT
if
on
is
None
:
on
=
self
.
_config
.
GetString
(
self
.
_section
)
if
on
is
None
:
on
=
self
.
_config
.
GetString
(
'
color.ui
'
)
...
...
This diff is collapsed.
Click to expand it.
main.py
+
6
−
0
View file @
42e679b9
...
...
@@ -36,6 +36,7 @@ try:
except
ImportError
:
kerberos
=
None
from
color
import
SetDefaultColoring
from
trace
import
SetTrace
from
git_command
import
git
,
GitCommand
from
git_config
import
init_ssh
,
close_ssh
...
...
@@ -69,6 +70,9 @@ global_options.add_option('-p', '--paginate',
global_options
.
add_option
(
'
--no-pager
'
,
dest
=
'
no_pager
'
,
action
=
'
store_true
'
,
help
=
'
disable the pager
'
)
global_options
.
add_option
(
'
--color
'
,
choices
=
(
'
auto
'
,
'
always
'
,
'
never
'
),
default
=
None
,
help
=
'
control color usage: auto, always, never
'
)
global_options
.
add_option
(
'
--trace
'
,
dest
=
'
trace
'
,
action
=
'
store_true
'
,
help
=
'
trace git command execution
'
)
...
...
@@ -113,6 +117,8 @@ class _Repo(object):
print
(
'
fatal: invalid usage of --version
'
,
file
=
sys
.
stderr
)
return
1
SetDefaultColoring
(
gopts
.
color
)
try
:
cmd
=
self
.
commands
[
name
]
except
KeyError
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment