Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong first argument in system

Tags:

ruby

system

In a git repository. I want to get the number of commits against remote origin's master branch:

remote = 'origin'
system %W[git rev-list HEAD...#{remote}/master --count]

This will result in ArgumentError: wrong first argument.

But git rev-list HEAD...#{remote}/master --count works.

what's wrong with my first argument?

like image 853
Juanito Fatas Avatar asked May 23 '14 07:05

Juanito Fatas


1 Answers

Need to use splat operator to convert the array to method parameters:

system *%W[git rev-list HEAD...#{remote}/master --count]
like image 159
Juanito Fatas Avatar answered Sep 30 '22 13:09

Juanito Fatas