Skip to content

@cookbooks /gist:731502

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Grit clone example
# Since Git is well structured, Grit uses a method missing (Grit::Git#method_missing) to 'systematically' execute Git commands:
require 'grit'
include Grit
gritty ='/tmp/filling-in')
gritty.clone({:quiet => false, :verbose => true, :progress => true, :branch => '37s'}, "git://", "/tmp/cc-aws2")
# => "Initialized empty Git repository in /tmp/cc-aws2/.git/\n"
# => 10

Trying the above, I get the following error:

eError: can't convert nil into String
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/grit-2.4.1/lib/grit/process.rb:290:in `spawn'
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/grit-2.4.1/lib/grit/process.rb:290:in `spawn'
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/grit-2.4.1/lib/grit/process.rb:271:in `popen4'
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/grit-2.4.1/lib/grit/process.rb:97:in `exec!'
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/grit-2.4.1/lib/grit/process.rb:68:in `initialize'
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/grit-2.4.1/lib/grit/git.rb:301:in `new'
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/grit-2.4.1/lib/grit/git.rb:301:in `native'
     from C:/Ruby192/lib/ruby/gems/1.9.1/gems/grit-2.4.1/lib/grit/git.rb:325:in `method_missing'
     from (irb):10
     from C:/Ruby192/bin/irb:12:in `<main>'

Sorry, that repo you are pointing at: git://
no longer exists.

gritty.clone({:quiet => false, :verbose => true, :progress => true, :branch => '37s'}, "git://", "/tmp/aws2")


PS Just in case there is a misunderstanding, this gist is to illustrate Grit usage not Chef or cookbooks access.


is it possible to clone a private repository?


I believe that this is simply a "magic" interface to standard git commands, so:

gritty.clone({:quiet => false, :verbose => true, :progress => true, :branch => '37s'}, "git://", "/tmp/cc-aws2")

equates to the git command line:

git clone -v --progress -b 37s git:// /tmp/cc-aws2

So, if your git user is authenticated to clone from that repo, then you should be able to with the Ruby snippet just as if you were running the command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.