Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
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 = Grit::Git.new('/tmp/filling-in')
gritty.clone({:quiet => false, :verbose => true, :progress => true, :branch => '37s'}, "git://github.com/cookbooks/cc-aws.git", "/tmp/cc-aws2")
# => "Initialized empty Git repository in /tmp/cc-aws2/.git/\n"
Dir.entries('/tmp/cc-aws2').size
# => 10
@jfoshee

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>'
@hedgehog

Sorry, that repo you are pointing at: git://github.com/cookbooks/cc-aws.git
no longer exists.

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

HTH?

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

@rtacconi

is it possible to clone a private repository?

@RyanScottLewis

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://github.com/cookbooks/cc-aws.git", "/tmp/cc-aws2")

equates to the git command line:

git clone -v --progress -b 37s git://github.com/cookbooks/cc-aws.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.