updatePath method

Future<void> updatePath(
  1. String path,
  2. GitHash hash
)

Implementation

Future<void> updatePath(String path, GitHash hash) async {
  var entry = entries.firstWhereOrNull((e) => e.path == path);
  if (entry == null) {
    var stat = await FileStat.stat(path);
    var entry = GitIndexEntry.fromFS(path, stat, hash);
    entries.add(entry);
    return;
  }

  var stat = await FileStat.stat(path);

  // Existing file
  entry.hash = hash;
  entry.fileSize = stat.size;

  entry.cTime = stat.changed;
  entry.mTime = stat.modified;
}