Juanito Fatas
Juanito Fatas

Reputation: 9969

Wrong first argument in 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?

Upvotes: 6

Views: 1161

Answers (1)

Juanito Fatas
Juanito Fatas

Reputation: 9969

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

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

Upvotes: 9

Related Questions