Re: [PATCH v2 01/44] Add support for ruby commands
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- Sep 29, 2013, 04:30 UTC
- Message-ID
- <CALkWK0m+LW-R-WJ6DmQkf1GKbCgvpzaGc2=rCNnmiPkf8x_qLg@mail.gmail.com>
- In-Reply-To
- <1380405849-13000-2-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras wrote:
Show 12 quoted lines
> +test_expect_success 'argument passing' ' > + cat > script <<-"EOF" && > + p($0) > + p(ARGV) > + EOF > + git ruby script foo bar > actual && > + cat > expected <<-EOF && > + "script" > + ["foo", "bar"] > + EOF > + test_cmp expected actual > +'
So, git-ruby is a new builtin that's just like a ruby interpreter, except that it has certain git-related functions defined: you pass it source code on stdin, and it returns the result on stdout. I wonder what the purpose of passing arguments to it is though.
Show 10 quoted lines
> +test_expect_success 'test for_each_ref()' ' > + test_commit foo && > + git ruby > actual <<-EOF && > + for_each_ref() do |name, sha1, flags| > + puts "%s: %s" % [name, sha1_to_hex(sha1)] > + end > + EOF > + git for-each-ref --format="%(refname): %(objectname)" > expected && > + test_cmp expected actual > +'
I find it interesting that you chose to implement for-each-ref in the initial version. It currently takes no arguments, but we can always extend it to do ref-hierarchy filtering like f-e-r in the future.