Gitility.File (Gitility v0.4.0)

Copy Markdown View Source

The result of reading one file from a snapshot.

data is raw bytes and always authoritative. kind classifies the content under the configured policy:

  • :text — valid UTF-8 with no binary marker;
  • :binary — everything else;
  • :symlink — the blob is a symlink target (never followed);
  • :gitlink — a submodule pointer (never opened).

When the read was line-sliced (lines:), start_line/end_line describe the returned slice. total_lines is the whole blob's line count when known — it is nil when the byte budget stopped the read before the full blob could be scanned, because reporting it would require reading what the caller asked us not to. truncated: true with total_lines: nil specifically indicates that the byte cap stopped the scan; a genuinely empty range reports total_lines and truncated: false.

lfs_pointer carries parsed Git LFS pointer metadata when the blob is a well-formed LFS pointer; the pointer text itself is still in data. Gitility identifies pointers but never resolves them. stats reports the work and cache activity performed by this read.

Summary

Types

Parsed LFS pointer metadata.

t()

Types

kind()

@type kind() :: :text | :binary | :symlink | :gitlink

lfs_pointer()

@type lfs_pointer() :: %{oid: String.t(), size: non_neg_integer()}

Parsed LFS pointer metadata.

t()

@type t() :: %Gitility.File{
  blob_oid: Gitility.OID.t(),
  data: binary(),
  end_line: pos_integer() | nil,
  kind: kind(),
  lfs_pointer: lfs_pointer() | nil,
  mode: non_neg_integer(),
  path: binary(),
  start_line: pos_integer() | nil,
  stats: Gitility.Stats.t(),
  total_lines: non_neg_integer() | nil,
  truncated: boolean()
}