writeObject method
Implementation
Future<GitHash> writeObject(GitObject obj) async {
var result = obj.serialize();
var hash = GitHash.compute(result);
var sha = hash.toString();
var path =
p.join(_gitDir, 'objects', sha.substring(0, 2), sha.substring(2));
await _fs.directory(p.dirname(path)).create(recursive: true);
var exists = await _fs.isFile(path);
if (exists) {
return hash;
}
var file = await _fs.file(path).open(mode: FileMode.writeOnly);
await file.writeFrom(zlib.encode(result));
await file.close();
return hash;
}