bur-manager/git2/git2.v

39 lines
693 B
V

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) !&GitRepository {
repo := &C.git_repository(0)
res := C.git_clone(&repo, url.str, path.str, 0)
if res != 0 {
return error('An error occured')
}
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')
}
}