Presubmit.FileChange (presubmit v0.2.2)

Copy Markdown View Source

One file's change between the before and after trees.

path is always the path that is meaningful after the change: the new path for renames and copies, and the old path for deletions (so that refute_removed/2 can match on it). old_path is set for renames and copies only.

Summary

Functions

The path of this file in the after tree, or nil for deletions.

The path of this file in the before tree, or nil for additions.

Builds a change record by diffing the file's contents in the two trees.

Files larger than this (in either version) are not line-diffed.

Types

status()

@type status() :: :added | :modified | :deleted | :renamed | :copied | :type_changed

t()

@type t() :: %Presubmit.FileChange{
  additions: non_neg_integer(),
  binary?: boolean(),
  deletions: non_neg_integer(),
  diffed?: boolean(),
  hunks: [Presubmit.Hunk.t()],
  old_path: String.t() | nil,
  path: String.t(),
  similarity: non_neg_integer() | nil,
  status: status()
}

Functions

after_path(file_change)

@spec after_path(t()) :: String.t() | nil

The path of this file in the after tree, or nil for deletions.

before_path(file_change)

@spec before_path(t()) :: String.t() | nil

The path of this file in the before tree, or nil for additions.

build(status, path, old_path, before, after_tree, opts \\ [])

@spec build(
  status(),
  String.t(),
  String.t() | nil,
  Presubmit.Tree.t(),
  Presubmit.Tree.t(),
  keyword()
) ::
  t()

Builds a change record by diffing the file's contents in the two trees.

Binary files (those containing a NUL byte, git's own heuristic) get no hunks and zero line counts, and so do files over max_diff_bytes/0 in either version, whose line diff would be too expensive; those are marked diffed?: false.

max_diff_bytes()

@spec max_diff_bytes() :: pos_integer()

Files larger than this (in either version) are not line-diffed.