Actually making some progress
This commit is contained in:
parent
1ac069bf28
commit
a4c2d0abd5
11 changed files with 155 additions and 7 deletions
|
|
@ -1,15 +1,29 @@
|
|||
module git2
|
||||
|
||||
#flag -lgit2
|
||||
//#flag -I @VMODROOT/c
|
||||
//#flag @VMODROOT/c/wrappers.o
|
||||
|
||||
#flag -lgit2
|
||||
#include "git2.h"
|
||||
|
||||
pub struct C.git_repository {}
|
||||
|
||||
pub struct C.git_remote {}
|
||||
|
||||
pub struct C.git_clone_options {}
|
||||
|
||||
pub struct C.git_strarray {}
|
||||
|
||||
pub struct C.git_fetch_options {}
|
||||
|
||||
fn C.git_libgit2_init()
|
||||
|
||||
fn C.git_libgit2_shutdown()
|
||||
|
||||
fn C.git_clone(&&C.git_repository, &char, &char, &C.git_clone_options) int
|
||||
|
||||
fn C.git_remote_create(&&C.git_remote, &C.git_repository, &char, &char) int
|
||||
|
||||
fn C.git_remote_fetch(&C.git_remote, &C.git_strarray, &C.git_fetch_options, &char) int
|
||||
|
||||
// fn C.vgit_clone(&char, &char) &C.git_repository
|
||||
|
|
|
|||
32
git2/git2.v
32
git2/git2.v
|
|
@ -1,16 +1,38 @@
|
|||
module git2
|
||||
|
||||
type GitRepository = C.git_repository
|
||||
type GitRemote = C.git_remote
|
||||
|
||||
fn init() {
|
||||
C.git_libgit2_init()
|
||||
}
|
||||
|
||||
pub fn clone(url string, path string) !&C.git_repository {
|
||||
out := &C.git_repository{}
|
||||
res := C.git_clone(&out, url.str, path.str, 0)
|
||||
pub fn clone(url string, path string) !&GitRepository {
|
||||
repo := &C.git_repository(0)
|
||||
res := C.git_clone(&repo, url.str, path.str, 0)
|
||||
|
||||
if res != 0 {
|
||||
return error('Exit code $res')
|
||||
return error('An error occured')
|
||||
}
|
||||
|
||||
return out
|
||||
return repo
|
||||
}
|
||||
|
||||
pub fn (r &GitRepository) create_remote(name string, url string) !&GitRemote {
|
||||
remote := &C.git_remote(0)
|
||||
res := C.git_remote_create(&remote, r, name.str, url.str)
|
||||
|
||||
if res != 0 {
|
||||
return error('An error occured')
|
||||
}
|
||||
|
||||
return remote
|
||||
}
|
||||
|
||||
pub fn (r &GitRemote) fetch() ! {
|
||||
res := C.git_remote_fetch(r, 0, 0, 0)
|
||||
|
||||
if res != 0 {
|
||||
return error('An error occured')
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3
git2/v.mod
Normal file
3
git2/v.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Module{
|
||||
name: 'git2'
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue