Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7cc871dd
Commit
7cc871dd
authored
Feb 05, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add colors to terminal output
This makes spotting anomolous queries easier.
parent
bcb377af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
lib/tasks/gitlab/graphql.rake
lib/tasks/gitlab/graphql.rake
+16
-4
No files found.
lib/tasks/gitlab/graphql.rake
View file @
7cc871dd
...
...
@@ -48,9 +48,21 @@ namespace :gitlab do
if
summary
==
:client_query
$stdout
.
puts
" - client query"
elsif
errs
.
present?
$stdout
.
puts
" - invalid query"
$stdout
.
puts
" - invalid query"
.
color
(
:red
)
else
$stdout
.
puts
" - complexity:
#{
defn
.
complexity
(
GitlabSchema
)
}
"
complexity
=
defn
.
complexity
(
GitlabSchema
)
color
=
case
complexity
when
0
..
GitlabSchema
::
DEFAULT_MAX_COMPLEXITY
:green
when
GitlabSchema
::
DEFAULT_MAX_COMPLEXITY
..
GitlabSchema
::
AUTHENTICATED_COMPLEXITY
:yellow
when
GitlabSchema
::
AUTHENTICATED_COMPLEXITY
..
GitlabSchema
::
ADMIN_COMPLEXITY
:orange
else
:red
end
$stdout
.
puts
" - complexity:
#{
complexity
}
"
.
color
(
color
)
end
$stdout
.
puts
""
...
...
@@ -72,10 +84,10 @@ namespace :gitlab do
when
:client_query
warn
(
"SKIP
#{
defn
.
file
}
: client query"
)
else
warn
(
"
OK
#{
defn
.
file
}
"
)
if
errs
.
empty?
warn
(
"
#{
'OK'
.
color
(
:green
)
}
#{
defn
.
file
}
"
)
if
errs
.
empty?
errs
.
each
do
|
err
|
warn
(
<<~
MSG
)
ERROR
#{
defn
.
file
}
:
#{
err
.
message
}
(at
#{
err
.
path
.
join
(
'.'
)
}
)
#{
'ERROR'
.
color
(
:red
)
}
#{
defn
.
file
}
:
#{
err
.
message
}
(at
#{
err
.
path
.
join
(
'.'
)
}
)
MSG
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment