gitlabhq/gitlabhq — pull request #2890 by cameronyule (2013-02-02 20:34:38+00:00)
Title: OS X support for gitlab:check rake tasks

The `gitlab:check` (and other `:check`) rake tasks currently fail on OS X due to the `gid_for` method in TaskHelpers.rake manually parsing the /etc/group file:

```
$ bundle exec rake gitlab:check RAILS_ENV=production
Checking Environment ...

gitlab user is in gitg group? ... yes
Has no "-e" in ~git/.profile ... yes
Git configured for gitlab user? ... yes
Has python2? ... yes
python2 is supported version? ... yes

Checking Environment ... Finished

Checking Gitolite ...

Using recommended version ... yes
Repo umask is 0007 in .gitolite.rc? ... yes
Allow all Git config keys in .gitolite.rc ... yes
Config directory exists? ... yes
Config directory owned by git:gitg ... rake aborted!
undefined method `split' for nil:NilClass
/Users/gitlab/gitlab/lib/tasks/gitlab/task_helpers.rake:81:in `gid_for'
/Users/gitlab/gitlab/lib/tasks/gitlab/check.rake:533:in `check_dot_gitolite_user_and_group'
/Users/gitlab/gitlab/lib/tasks/gitlab/check.rake:400:in `block (3 levels) in '
Tasks: TOP => gitlab:check => gitlab:gitolite:check
(See full trace by running task with --trace)
```

While the `/etc/group` file exists on OS X it's only used for system services, with all user-created users and groups using Directory Services instead.

This simple pull request replaces the manual parsing of `/etc/group` with an equivalent call to the platform-independent [`Etc` class](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/etc/rdoc/Etc.html) from the standard library.

All tests continue to pass after this amend.