Refactor calls to pick `gmake`/`make` and `gtar`/`tar`
Summary
In several places of the codebase, we need to execute the commands make
or tar
. For that, we first ensure gmake
or gtar
don't exist in the system and fallback to make
and tar
. We do this several times.
I think the way to go is how ee/lib/tasks/gitlab/indexer.rake
implements it by calling Gitlab::Utils.which('gmake') || Gitlab::Utils.which('make')
.
We can add a method in Gitlab::TaskHelpers
like:
def make_cmd
Gitlab::Utils.which('gmake') || Gitlab::Utils.which('make')
end
def tar_cmd
Gitlab::Utils.which('gtar') || Gitlab::Utils.which('tar')
end
Improvements
We follow the DRY principle and remove repeated code. Besides, it seems Gitlab::Utils.which
is a cross-platform way to find if the command exists, instead of calling which
.
Involved components
The following will be the affected files
lib/tasks/gitlab/gitaly.rake
lib/tasks/gitlab/workhorse.rake
ee/lib/tasks/gitlab/indexer.rake
lib/backup/files.rb
Edited by Francisco Javier López (ex-Gitlab)