Skip to content

Commit 6b22524

Browse files
committed
[test_helper.rb] Add TestRepo.clone_at helper
Used to clone a repo (first arg) to a new directory (second arg). `TestRepo#clone` is added as well to assit with this as well.
1 parent 7647a60 commit 6b22524

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/test_helper.rb

+14
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ def self.generate repo_path, file_struct, &block
180180
repo.generate(&block)
181181
end
182182

183+
def self.clone_at url, dir, &block
184+
repo = new dir, []
185+
repo.clone(url, &block)
186+
end
187+
183188
def initialize repo_path, file_struct
184189
@commit_count = 0
185190
@repo_path = Pathname.new repo_path
@@ -197,6 +202,15 @@ def generate &block
197202
instance_eval(&block) if block_given?
198203
end
199204

205+
def clone url, &block
206+
@repo = Rugged::Repository.clone_at url, @repo_path.to_s
207+
@index = repo.index
208+
@last_commit = repo.last_commit
209+
# puts @repo.inspect
210+
211+
instance_eval(&block) if block_given?
212+
end
213+
200214
# Create a new branch (don't checkout)
201215
#
202216
# $ git branch other_branch

0 commit comments

Comments
 (0)