seed method

Future<GitObjectId> seed(
  1. Map<String, List<int>> files, {
  2. String? branch,
  3. String message = 'seed',
})

Makes a commit of files on branch directly on the server.

Implementation

Future<GitObjectId> seed(
  Map<String, List<int>> files, {
  String? branch,
  String message = 'seed',
}) async {
  final ref = 'refs/heads/${branch ?? defaultBranch}';
  final parent = await repository.refs.read(ref);
  final base = parent == null
      ? null
      : (await repository.readCommit(parent)).tree;
  final tree = await repository.editTree(base, writes: files);
  final commit = await repository.commit(
    tree: tree,
    parents: [?parent],
    message: message,
    author: GitPerson(
      name: 'Server',
      email: 'server@test',
      seconds: 1700000000,
    ),
  );
  await repository.refs.write(ref, commit);
  return commit;
}