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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
12b4bb59
Commit
12b4bb59
authored
Dec 07, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make gitlab:env:info task more robust
Closes #2213
parent
84465576
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
21 deletions
+39
-21
lib/tasks/gitlab/info.rake
lib/tasks/gitlab/info.rake
+39
-21
No files found.
lib/tasks/gitlab/info.rake
View file @
12b4bb59
namespace
:gitlab
do
namespace
:env
do
desc
"GITLAB | Show information about GitLab and its environment"
task
:info
=>
:environment
do
task
info:
:environment
do
# check which OS is running
if
Kernel
.
system
(
'lsb_release > /dev/null 2>&1'
)
os_name
=
`lsb_release -irs`
elsif
File
.
exists?
(
'/etc/system-release'
)
&&
File
.
readable?
(
'/etc/system-release'
)
os_name
=
File
.
read
(
'/etc/system-release'
)
elsif
File
.
exists?
(
'/etc/debian_version'
)
&&
File
.
readable?
(
'/etc/debian_version'
)
debian_version
=
File
.
read
(
'/etc/debian_version'
)
os_name
=
"Debian
#{
debian_version
}
"
end
os_name
=
os_name
.
gsub
(
/\n/
,
''
)
os_name
=
run
(
"lsb_release -irs"
)
os_name
||=
if
File
.
readable?
(
'/etc/system-release'
)
File
.
read
(
'/etc/system-release'
)
end
os_name
||=
if
File
.
readable?
(
'/etc/debian_version'
)
debian_version
=
File
.
read
(
'/etc/debian_version'
)
"Debian
#{
debian_version
}
"
end
os_name
.
squish!
# check if there is an RVM environment
m
,
rvm_version
=
`rvm --version`
.
match
(
/rvm ([\d\.]+) /
).
to_a
rvm_version
=
run_and_match
(
"rvm --version"
,
/[\d\.]+/
).
try
(
:to_s
)
# check Gem version
gem_version
=
run
(
"gem --version"
)
# check Bundler version
m
,
bunder_version
=
`bundle --version`
.
match
(
/Bundler version ([\d\.]+)/
).
to_a
bunder_version
=
run_and_match
(
"bundle --version"
,
/[\d\.]+/
).
try
(
:to_s
)
# check Bundler version
m
,
rake_version
=
`rake --version`
.
match
(
/rake, version ([\d\.]+)/
).
to_a
rake_version
=
run_and_match
(
"rake --version"
,
/[\d\.]+/
).
try
(
:to_s
)
puts
""
puts
"System information"
.
yellow
puts
"System:
\t\t
#{
os_name
}
"
puts
"System:
\t\t
#{
os_name
||
"unknown"
.
red
}
"
puts
"Current User:
\t
#{
`whoami`
}
"
puts
"Using RVM:
\t
#{
rvm_version
.
present?
?
"yes"
.
green
:
"no"
}
"
puts
"RVM Version:
\t
#{
rvm_version
}
"
if
rvm_version
.
present?
puts
"Ruby Version:
\t
#{
ENV
[
'RUBY_VERSION'
]
}
"
puts
"Gem Version:
\t
#{
`gem --version`
}
"
puts
"Bundler Version:
#{
bunder_version
}
"
puts
"Rake Version:
\t
#{
rake_version
}
"
puts
"Ruby Version:
\t
#{
ENV
[
'RUBY_VERSION'
]
||
"unknown"
.
red
}
"
puts
"Gem Version:
\t
#{
gem_version
||
"unknown"
.
red
}
"
puts
"Bundler Version:
#{
bunder_version
||
"unknown"
.
red
}
"
puts
"Rake Version:
\t
#{
rake_version
||
"unknown"
.
red
}
"
# check database adapter
...
...
@@ -61,13 +63,11 @@ namespace :gitlab do
gitolite_version_file
=
"
#{
Gitlab
.
config
.
git_base_path
}
/../gitolite/src/VERSION"
if
File
.
exists?
(
gitolite_version_file
)
&&
File
.
readable?
(
gitolite_version_file
)
gitolite_version
=
File
.
read
(
gitolite_version_file
)
else
gitolite_version
=
'unknown'
end
puts
""
puts
"Gitolite information"
.
yellow
puts
"Version:
\t
#{
gitolite_version
}
"
puts
"Version:
\t
#{
gitolite_version
||
"unknown"
.
red
}
"
puts
"Admin URI:
\t
#{
Gitlab
.
config
.
gitolite_admin_uri
}
"
puts
"Admin Key:
\t
#{
Gitlab
.
config
.
gitolite_admin_key
}
"
puts
"Repositories:
\t
#{
Gitlab
.
config
.
git_base_path
}
"
...
...
@@ -75,5 +75,23 @@ namespace :gitlab do
puts
"Git:
\t\t
#{
Gitlab
.
config
.
git
.
path
}
"
end
# Helper methods
# Runs the given command and matches the output agains the given RegExp
def
run_and_match
(
command
,
regexp
)
run
(
command
).
try
(
:match
,
regexp
)
end
# Runs the given command
#
# Returns nil if the command was not found
# Returns the output of the command otherwise
def
run
(
command
)
unless
`
#{
command
}
2>/dev/null`
.
blank?
`
#{
command
}
`
end
end
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