MoonBit bindings for libgit2 - Git operations from MoonBit
Dependencies
brew install libgit2sudo apt-get install libgit2-devsudo dnf install libgit2-devel{
"deps": {
"mizchi/libgit2": "0.1.0"
}
}fn main {
// Initialize libgit2
if not(@libgit2.git_init()) {
println("Failed to load libgit2")
return
}
// Open repository
match @libgit2.Repository::open(".") {
Some(repo) => {
println("Repository: \{repo.path()}")
// Get recent commits
let commits = repo.log(5)
for commit in commits {
println("[\{commit.id.substring(0, 7)}] \{commit.summary}")
}
repo.close()
}
None => println("Failed to open repository")
}
@libgit2.git_shutdown()
}Repository::open(path: String) -> Repository?
Repository::init(path: String, is_bare: Bool) -> Repository?
Repository::close(self: Repository) -> UnitRepository::log(self: Repository, max_count: Int) -> Array[CommitInfo]
Repository::head_commit(self: Repository) -> CommitInfo?Repository::branches(self: Repository, include_remote: Bool) -> Array[BranchInfo]
Repository::current_branch(self: Repository) -> String?moon test --target nativeMoonBit API (lib/run.mbt)
↓
C Wrapper (lib/stub.c)
↓
libgit2 (dynamic library)pub struct Blob {
// private fields
}pub struct CommitInfo {
id : String
message : String
summary : String
author_name : String
author_email : String
committer_name : String
committer_email : String
time : Int64
}pub struct DiffStats {
files_changed : Int
insertions : Int
deletions : Int
}pub struct Index {
// private fields
}pub struct RemoteInfo {
name : String
url : String
push_url : String
}pub struct Repository {
// private fields
}fn Repository::commit(self : Repository, message : String, author : Signature, committer : Signature, tree_oid : String) -> String?pub struct Signature {
// private fields
}pub struct StatusFlags {
flags : Int
}pub struct Tree {
// private fields
}MoonBit bindings for libgit2 - Git operations from MoonBit
Dependencies