ligit 0.0.1 copy "ligit: ^0.0.1" to clipboard
ligit: ^0.0.1 copied to clipboard

Idiomatic Dart bindings to libgit2, the portable C implementation of Git. Open, inspect, and manipulate repositories without shelling out.

example/example.dart

import 'dart:io';

import 'package:ligit/ligit.dart';

void main() {
  Libgit2.init();
  try {
    final tmp = Directory.systemTemp.createTempSync('ligit_example_');
    print('repo: ${tmp.path}');

    final repo = Repository.init(tmp.path);
    try {
      File('${tmp.path}/README.md').writeAsStringSync('# hello libgit2\n');

      final index = repo.index();
      index.addByPath('README.md');
      index.write();
      final treeId = index.writeTree();
      index.dispose();

      final author = Signature.now(name: 'Example', email: 'e@example.com');
      final tree = Tree.lookup(repo, treeId);
      final headOid = Commit.create(
        repo: repo,
        updateRef: 'HEAD',
        author: author,
        committer: author,
        message: 'initial commit\n',
        tree: tree,
      );
      tree.dispose();

      print('HEAD: ${headOid.sha}');
    } finally {
      repo.dispose();
      tmp.deleteSync(recursive: true);
    }
  } finally {
    Libgit2.shutdown();
  }
}
1
likes
140
points
18
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Idiomatic Dart bindings to libgit2, the portable C implementation of Git. Open, inspect, and manipulate repositories without shelling out.

Repository (GitHub)
View/report issues

Topics

#git #libgit2 #vcs #ffi

License

MIT (license)

Dependencies

code_assets, crypto, ffi, hooks, meta

More

Packages that depend on ligit