Commit a213d4b9e80fed7a8ad38185d2a93e6def295e50
1 parent
fd836f54
Exists in
master
and in
4 other branches
Move OS detection to task helpers and add detection of OS X
Showing
2 changed files
with
22 additions
and
14 deletions
Show diff stats
lib/tasks/gitlab/info.rake
... | ... | @@ -3,20 +3,6 @@ namespace :gitlab do |
3 | 3 | desc "GITLAB | Show information about GitLab and its environment" |
4 | 4 | task info: :environment do |
5 | 5 | |
6 | - # check which OS is running | |
7 | - os_name = run("lsb_release -irs") | |
8 | - os_name ||= if File.readable?('/etc/system-release') | |
9 | - File.read('/etc/system-release') | |
10 | - end | |
11 | - os_name ||= if File.readable?('/etc/debian_version') | |
12 | - debian_version = File.read('/etc/debian_version') | |
13 | - "Debian #{debian_version}" | |
14 | - end | |
15 | - os_name ||= if File.readable?('/etc/SuSE-release') | |
16 | - File.read('/etc/SuSE-release') | |
17 | - end | |
18 | - os_name.try(:squish!) | |
19 | - | |
20 | 6 | # check if there is an RVM environment |
21 | 7 | rvm_version = run_and_match("rvm --version", /[\d\.]+/).try(:to_s) |
22 | 8 | # check Ruby version | ... | ... |
lib/tasks/gitlab/task_helpers.rake
1 | 1 | namespace :gitlab do |
2 | 2 | |
3 | + # Check which OS is running | |
4 | + # | |
5 | + # It will primarily use lsb_relase to determine the OS. | |
6 | + # It has fallbacks to Debian, SuSE and OS X. | |
7 | + def os_name | |
8 | + os_name = run("lsb_release -irs") | |
9 | + os_name ||= if File.readable?('/etc/system-release') | |
10 | + File.read('/etc/system-release') | |
11 | + end | |
12 | + os_name ||= if File.readable?('/etc/debian_version') | |
13 | + debian_version = File.read('/etc/debian_version') | |
14 | + "Debian #{debian_version}" | |
15 | + end | |
16 | + os_name ||= if File.readable?('/etc/SuSE-release') | |
17 | + File.read('/etc/SuSE-release') | |
18 | + end | |
19 | + os_name ||= if os_x_version = run("sw_vers -productVersion") | |
20 | + "Mac OS X #{os_x_version}" | |
21 | + end | |
22 | + os_name.try(:squish!) | |
23 | + end | |
24 | + | |
3 | 25 | # Runs the given command and matches the output agains the given pattern |
4 | 26 | # |
5 | 27 | # Returns nil if nothing matched | ... | ... |