Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
GitLab Development Kit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
GitLab Development Kit
Commits
17aa2b69
Commit
17aa2b69
authored
1 week ago
by
Doug Barrett
Browse files
Options
Downloads
Patches
Plain Diff
Refactor for maintainability
parent
c78654f1
No related branches found
No related tags found
Loading
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/gdk/command/doctor.rb
+16
-13
16 additions, 13 deletions
lib/gdk/command/doctor.rb
lib/gdk/diagnostic/git_maintenance.rb
+0
-4
0 additions, 4 deletions
lib/gdk/diagnostic/git_maintenance.rb
spec/lib/gdk/command/doctor_spec.rb
+14
-2
14 additions, 2 deletions
spec/lib/gdk/command/doctor_spec.rb
with
30 additions
and
19 deletions
lib/gdk/command/doctor.rb
+
16
−
13
View file @
17aa2b69
...
...
@@ -24,18 +24,7 @@ module GDK
show_results
(
diagnostic_results
)
return
2
if
@unexpected_error
out
.
puts
(
"
\n
"
)
if
correctable_results
.
any?
if
@should_autocorrect
perform_corrections
else
out
.
info
(
"You may autocorrect
#{
correctable_results
.
size
}
problems by running `gdk doctor --correct` or `gdk doctor -C`"
)
end
elsif
@should_autocorrect
out
.
warn
(
'No problems to autocorrect.'
)
end
handle_correctable_results
(
correctable_results
)
return
2
if
@unexpected_error
diagnostic_results
.
empty?
...
...
@@ -48,7 +37,7 @@ module GDK
def
installed?
# TODO: Eventually, the Procfile will no longer exists so we need a better
# way to determine this, but this will be OK for now.
GDK
.
root
.
join
(
'Procfile'
)
&
.
exist?
GDK
.
root
.
join
(
'Procfile'
).
exist?
end
def
diagnostic_results
...
...
@@ -91,6 +80,20 @@ module GDK
diagnostic
end
def
handle_correctable_results
(
correctable_results
)
out
.
puts
(
"
\n
"
)
if
correctable_results
.
any?
if
@should_autocorrect
perform_corrections
else
out
.
info
(
"You may autocorrect
#{
correctable_results
.
size
}
problems by running `gdk doctor --correct` or `gdk doctor -C`"
)
end
elsif
@should_autocorrect
out
.
warn
(
'No problems to autocorrect.'
)
end
end
def
start_necessary_services
Runit
.
start
(
'postgresql'
,
quiet:
true
)
# Give services a chance to start up..
...
...
This diff is collapsed.
Click to expand it.
lib/gdk/diagnostic/git_maintenance.rb
+
0
−
4
View file @
17aa2b69
...
...
@@ -5,10 +5,6 @@ module GDK
class
GitMaintenance
<
Base
TITLE
=
'Git Maintenance Recommendation'
def
correctable?
true
end
def
success?
repos_without_git_maintenance
.
empty?
end
...
...
This diff is collapsed.
Click to expand it.
spec/lib/gdk/command/doctor_spec.rb
+
14
−
2
View file @
17aa2b69
...
...
@@ -5,11 +5,11 @@ require 'stringio'
RSpec
.
describe
GDK
::
Command
::
Doctor
,
:hide_output
do
# rubocop:todo RSpec/VerifiedDoubles
let
(
:successful_diagnostic
)
do
double
(
GDK
::
Diagnostic
,
unexpected_error:
nil
,
success?:
true
,
correctable?:
tru
e
,
correct?:
tru
e
,
message:
nil
)
double
(
GDK
::
Diagnostic
,
unexpected_error:
nil
,
success?:
true
,
correctable?:
fals
e
,
correct?:
fals
e
,
message:
nil
)
end
let
(
:failing_diagnostic
)
do
double
(
GDK
::
Diagnostic
,
unexpected_error:
nil
,
success?:
false
,
correctable?:
tru
e
,
correct?:
tru
e
,
message:
'check failed'
)
double
(
GDK
::
Diagnostic
,
unexpected_error:
nil
,
success?:
false
,
correctable?:
fals
e
,
correct?:
fals
e
,
message:
'check failed'
)
end
let
(
:correctable_diagnostic
)
do
...
...
@@ -89,6 +89,12 @@ RSpec.describe GDK::Command::Doctor, :hide_output do
expect
(
subject
.
run
).
to
be
(
false
)
end
it
'does not attempt to correct failed diagnostics'
do
expect
(
failing_diagnostic
).
not_to
receive
(
:correct?
)
expect
(
subject
.
run
).
to
be
(
false
)
end
it
'prints a warning'
do
expect
(
GDK
::
Output
).
to
receive
(
:puts
).
with
(
"
\n
"
).
ordered
expect
(
GDK
::
Output
).
to
receive
(
:warn
).
with
(
'Your GDK may need attention.'
).
ordered
...
...
@@ -114,6 +120,12 @@ RSpec.describe GDK::Command::Doctor, :hide_output do
expect
(
subject
.
run
).
to
be
(
false
)
end
it
'does not attempt to correct failed diagnostics'
do
expect
(
failing_diagnostic
).
not_to
receive
(
:correct?
)
expect
(
subject
.
run
).
to
be
(
false
)
end
it
'does not check if successful diagnostics are correctable'
do
expect
(
successful_diagnostic
).
not_to
receive
(
:correctable?
)
...
...
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