commitFiles method
Commits files (path → text) onto branch, creating it if needed.
The direct way for a test to play the part of a competing writer.
Implementation
String commitFiles(
String slug,
Map<String, String> files, {
String branch = 'main',
String message = 'test',
}) {
final r = repo(slug);
final ref = 'heads/$branch';
final parent = r.refs[ref];
final base = parent == null
? <String, String>{}
: {...trees[commits[parent]!.treeSha]!};
for (final file in files.entries) {
base[file.key] = _putBlob(utf8.encode(file.value));
}
final treeSha = _putTree(base);
final commitSha = _putCommit(FakeCommit(treeSha, [?parent], message));
r.refs[ref] = commitSha;
return commitSha;
}