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
a86f48c7
Commit
a86f48c7
authored
Mar 21, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper method to return a human-friendly name for database adapter
parent
134df14c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
6 deletions
+22
-6
app/views/admin/dashboard/index.html.haml
app/views/admin/dashboard/index.html.haml
+1
-1
config/initializers/console_message.rb
config/initializers/console_message.rb
+1
-1
lib/gitlab/database.rb
lib/gitlab/database.rb
+4
-0
lib/tasks/gitlab/info.rake
lib/tasks/gitlab/info.rake
+2
-4
spec/lib/gitlab/database_spec.rb
spec/lib/gitlab/database_spec.rb
+14
-0
No files found.
app/views/admin/dashboard/index.html.haml
View file @
a86f48c7
...
...
@@ -163,7 +163,7 @@
%span
.float-right
#{
Rails
::
VERSION
::
STRING
}
%p
=
Gitlab
::
Database
.
adapter_name
=
Gitlab
::
Database
.
human_
adapter_name
%span
.float-right
=
Gitlab
::
Database
.
version
%p
...
...
config/initializers/console_message.rb
View file @
a86f48c7
...
...
@@ -5,6 +5,6 @@ if defined?(Rails::Console)
puts
"-------------------------------------------------------------------------------------"
puts
" GitLab:"
.
ljust
(
justify
)
+
"
#{
Gitlab
::
VERSION
}
(
#{
Gitlab
.
revision
}
)"
puts
" GitLab Shell:"
.
ljust
(
justify
)
+
"
#{
Gitlab
::
VersionInfo
.
parse
(
Gitlab
::
Shell
.
new
.
version
)
}
"
puts
"
#{
Gitlab
::
Database
.
adapter_name
}
:"
.
ljust
(
justify
)
+
Gitlab
::
Database
.
version
puts
"
#{
Gitlab
::
Database
.
human_
adapter_name
}
:"
.
ljust
(
justify
)
+
Gitlab
::
Database
.
version
puts
"-------------------------------------------------------------------------------------"
end
lib/gitlab/database.rb
View file @
a86f48c7
...
...
@@ -27,6 +27,10 @@ module Gitlab
config
[
'adapter'
]
end
def
self
.
human_adapter_name
postgresql?
?
'PostgreSQL'
:
'MySQL'
end
def
self
.
mysql?
adapter_name
.
casecmp
(
'mysql2'
).
zero?
end
...
...
lib/tasks/gitlab/info.rake
View file @
a86f48c7
...
...
@@ -34,9 +34,6 @@ namespace :gitlab do
puts
"Sidekiq Version:
#{
Sidekiq
::
VERSION
}
"
puts
"Go Version:
\t
#{
go_version
[
1
]
||
"unknown"
.
color
(
:red
)
}
"
# check database adapter
database_adapter
=
ActiveRecord
::
Base
.
connection
.
adapter_name
.
downcase
project
=
Group
.
new
(
path:
"some-group"
).
projects
.
build
(
path:
"some-project"
)
# construct clone URLs
http_clone_url
=
project
.
http_url_to_repo
...
...
@@ -49,7 +46,8 @@ namespace :gitlab do
puts
"Version:
\t
#{
Gitlab
::
VERSION
}
"
puts
"Revision:
\t
#{
Gitlab
.
revision
}
"
puts
"Directory:
\t
#{
Rails
.
root
}
"
puts
"DB Adapter:
\t
#{
database_adapter
}
"
puts
"DB Adapter:
\t
#{
Gitlab
::
Database
.
human_adapter_name
}
"
puts
"DB Version:
\t
#{
Gitlab
::
Database
.
version
}
"
puts
"URL:
\t\t
#{
Gitlab
.
config
.
gitlab
.
url
}
"
puts
"HTTP Clone URL:
\t
#{
http_clone_url
}
"
puts
"SSH Clone URL:
\t
#{
ssh_clone_url
}
"
...
...
spec/lib/gitlab/database_spec.rb
View file @
a86f48c7
...
...
@@ -17,6 +17,20 @@ describe Gitlab::Database do
end
end
describe
'.human_adapter_name'
do
it
'returns PostgreSQL when using PostgreSQL'
do
allow
(
described_class
).
to
receive
(
:postgresql?
).
and_return
(
true
)
expect
(
described_class
.
human_adapter_name
).
to
eq
(
'PostgreSQL'
)
end
it
'returns MySQL when using MySQL'
do
allow
(
described_class
).
to
receive
(
:postgresql?
).
and_return
(
false
)
expect
(
described_class
.
human_adapter_name
).
to
eq
(
'MySQL'
)
end
end
# These are just simple smoke tests to check if the methods work (regardless
# of what they may return).
describe
'.mysql?'
do
...
...
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