fromFS static method

GitIndexEntry fromFS(
  1. String path,
  2. FileStat stat,
  3. GitHash hash
)

Implementation

static GitIndexEntry fromFS(String path, FileStat stat, GitHash hash) {
  var cTime = stat.changed;
  var mTime = stat.modified;
  var mode = GitFileMode(stat.mode);

  // These don't seem to be exposed in Dart
  var ino = 0;
  var dev = 0;

  switch (stat.type) {
    case FileSystemEntityType.file:
      mode = GitFileMode.Regular;
      break;
    case FileSystemEntityType.directory:
      mode = GitFileMode.Dir;
      break;
    case FileSystemEntityType.link:
      mode = GitFileMode.Symlink;
      break;
  }

  // Don't seem accessible in Dart -https://github.com/dart-lang/sdk/issues/15078
  var uid = 0;
  var gid = 0;

  var fileSize = stat.size;
  var stage = GitFileStage(0);

  assert(!path.startsWith('/'));
  return GitIndexEntry(
    cTime: cTime,
    mTime: mTime,
    dev: dev,
    ino: ino,
    mode: mode,
    uid: uid,
    gid: gid,
    fileSize: fileSize,
    hash: hash,
    stage: stage,
    path: path,
  );
}