Skip to main content
Get structured diff data between two changes. Required scope: read
const diff = await mesa.diffs.get({
  repo: 'app',
  base_change_id: 'zyxwvutsrqponmlkzyxwvutsrqponmlk',
  head_change_id: 'yxwvutsrqponmlkzyxwvutsrqponmlkz',
  conflicts: 'include',
});

console.log(diff.stats.additions, diff.stats.deletions);
Get only conflict details:
const conflicts = await mesa.diffs.get({
  repo: 'app',
  base_change_id: 'zyxwvutsrqponmlkzyxwvutsrqponmlk',
  head_change_id: 'yxwvutsrqponmlkzyxwvutsrqponmlkz',
  conflicts: 'only',
});

Options

repo
string
required
Repository name.
base_change_id
string
required
Base change ID.
head_change_id
string
required
Head change ID.
org
string | undefined
Organization override.
conflicts
'include' | 'only' | 'exclude' | undefined
Conflict detail mode. Defaults to include.

Response

entries[] and conflicted_entries[] are mutually exclusive: unresolved conflicted paths appear only in conflicted_entries[].
base_change_id
string
Base change used for comparison.
head_change_id
string
Head change used for comparison.
stats
DiffStats
Aggregate counts for the response.
truncated
boolean
Whether the response hit the server entry limit and is incomplete.
entries
DiffEntry[]
Structural changed entries. Unchanged paths are omitted.
conflicted_entries
ConflictedDiffEntry[]
Conflict-only details for unresolved paths.

DiffStats

entries
number
Number of structural entries returned in entries[].
additions
number
Total added lines across textual diff hunks.
deletions
number
Total deleted lines across textual diff hunks.
changes
number
Sum of additions and deletions.
conflicted_entries
number
Number of paths returned in conflicted_entries[].
conflicted_hunks
number
Total conflict hunk count across conflicted_entries[].

DiffEntry

path
string
Repository-relative path at the head change.
status
'added' | 'modified' | 'deleted' | 'renamed'
How the entry changed between the base and head changes.
old_path
string | null
Previous repository-relative path for renamed entries. Null for non-renames.
size_bytes
number | undefined
Approximate size in bytes of the changed entry content, not the textual diff.
is_conflicted
boolean
Always false for entries returned in entries[]. Conflicted paths are returned in conflicted_entries[].
omitted_reason
'binary' | 'too_large' | 'file_limit' | null
Why textual hunk data is unavailable. Null when hunks is present.
hunks
DiffHunk[] | null
Structured textual diff hunks. Null when omitted_reason is set.
conflict_hunks
DiffConflictHunk[] | null
Structured conflict hunks for the entry, or null when there are none. Structural entries in entries[] normally return null.

DiffHunk

old_start
number
Starting line number in the base side.
old_lines
number
Number of base-side lines covered by the hunk.
new_start
number
Starting line number in the head side.
new_lines
number
Number of head-side lines covered by the hunk.
lines
DiffLine[]
Lines in this textual diff hunk.

DiffLine

kind
'context' | 'added' | 'deleted' | 'annotation'
Line classification inside a textual diff hunk.
text
string
Line text.

ConflictedDiffEntry

path
string
Repository-relative path for the unresolved conflict.
hunks
DiffConflictHunk[]
Per-hunk conflict detail. Empty when omitted_reason is set or the conflict is non-textual.
size_bytes
number | undefined
Approximate size in bytes of the largest side of the conflict.
omitted_reason
'binary' | 'too_large' | null | undefined
Why hunk data is unavailable. When set, fetch file bytes with mesa.content.get() against the target or source change to compose a whole-file resolution.

DiffConflictHunk

hunk_id
string
Stable identifier for the conflict hunk.
old_start
number
Starting line number in the base side.
old_lines
number
Number of base-side lines covered by the hunk.
new_start
number
Starting line number in the head side.
new_lines
number
Number of head-side lines covered by the hunk.
target
ChangeConflictHunkSide | null
Target side of the conflicted hunk.
base
ChangeConflictHunkSide | null
Base side of the conflicted hunk.
source
ChangeConflictHunkSide | null
Source side of the conflicted hunk.

ChangeConflictHunkSide

content
string
Base64-encoded raw bytes for this side of the conflicted hunk.