Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Miscellaneous Changes

Add clone function
Update few tests
  • Loading branch information...
commit cb6b10e97fc5b8e16641901611e5350e78344838 1 parent 4dab753
@sa1 sa1 authored
Showing with 22 additions and 13 deletions.
  1. +5 −7 src/Git2/Repository.winxed
  2. +17 −6 t/winxed/001_load.t
View
12 src/Git2/Repository.winxed
@@ -82,8 +82,9 @@ namespace Git2 {
using Git2.Git.init_repository2;
self.ptr = init_repository2(cstring(x), bare);
}
- function clone(path, url){
- //TODO
+ function clone(url, path){
+ using Git2.Git.clone;
+ self.ptr = clone(cstring(url), cstring(path));
}
/*
* Check if shallow - 1 if shallow, 0 otherwise
@@ -117,13 +118,10 @@ namespace Git2 {
var bool = git_repository_free(self.ptr);
return bool;
}
- /*
- * Get Path.
- * TODO: convert to parrot string
- */
function path(){
using Git2.Raw.git_repository_path;
- var path = git_repository_path(self.ptr);
+ var cpath = git_repository_path(self.ptr);
+ string path = atos(cpath);
return path;
}
/*
View
23 t/winxed/001_load.t
@@ -58,6 +58,16 @@ class Test_git2_repository_open {
self.assert.defined(str,"cstring is defined");
}
+ function test_atos(){
+ string s = "foo";
+ string r;
+
+ var x = cstring(s);
+ r = atos(x);
+
+ self.assert.equal(r, "foo");
+ }
+
function open_repo() {
using Git2.Repository;
using Git2.Raw.git_repository_open;
@@ -109,20 +119,21 @@ class Test_git2_repository_open {
function create_repo(){
using Git2.Repository;
- var repo = new Repository;
+ var repo = new Git2.Repository();
var rc1 = repo.init_repo("/tmp/test");
+ string path = repo.path();
+ self.assert.equal(path, "/tmp/test/.git/");
repo.free();
}
function clone_repo(){
using Git2.Repository;
- var repo = new Repository;
+ var repo = new Git2.Repository();
repo.clone("https://github.com/letolabs/parrot-libgit2.git", "/tmp/parrot");
- int rc1 = repo.is_empty();
- self.assert.equal(rc1, 0);
- repo.free();
- //TODO: remove cloned directory
+ var ptr = repo.get_pointer();
+ self.assert.defined(ptr, "Repository not cloned.");
+
}
function show_branch(){
Please sign in to comment.
Something went wrong with that request. Please try again.