From cb6d7e5192c926b61d8cbdd4f4e0d45813ed7a09 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 12 Sep 2013 15:28:46 +0200 Subject: [PATCH] Rescue an error if group doesn't exist --- lib/tasks/gitlab/check.rake | 6 ++++-- lib/tasks/gitlab/task_helpers.rake | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 74b3e77..1e9228a 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -479,11 +479,13 @@ namespace :gitlab do return end - if File.stat(repo_base_path).uid == uid_for(gitlab_shell_ssh_user) && - File.stat(repo_base_path).gid == gid_for(gitlab_shell_owner_group) + uid = uid_for(gitlab_shell_ssh_user) + gid = gid_for(gitlab_shell_owner_group) + if File.stat(repo_base_path).uid == uid && File.stat(repo_base_path).gid == gid puts "yes".green else puts "no".red + puts " User id for #{gitlab_shell_ssh_user}: #{uid}. Groupd id for #{gitlab_shell_owner_group}: #{gid}".blue try_fixing_it( "sudo chown -R #{gitlab_shell_ssh_user}:#{gitlab_shell_owner_group} #{repo_base_path}" ) diff --git a/lib/tasks/gitlab/task_helpers.rake b/lib/tasks/gitlab/task_helpers.rake index f84257d..ac2c457 100644 --- a/lib/tasks/gitlab/task_helpers.rake +++ b/lib/tasks/gitlab/task_helpers.rake @@ -80,7 +80,11 @@ namespace :gitlab do end def gid_for(group_name) - Etc.getgrnam(group_name).gid + begin + Etc.getgrnam(group_name).gid + rescue ArgumentError # no group + "group #{group_name} doesn't exist" + end end def warn_user_is_not_gitlab -- libgit2 0.21.2