Files
pipelines/app/lib/features/changes/domain/patch_models.dart
T

60 lines
1.3 KiB
Dart

/// Patch value objects produced by the unified-patch parser. Kept separate from
/// the parser so widgets import the smallest model they need.
library;
enum ChangeLineKind { context, add, remove }
class PatchLine {
const PatchLine({
required this.kind,
required this.text,
required this.oldLine,
required this.newLine,
this.noNewlineMarker = false,
});
final ChangeLineKind kind;
final String text;
final int oldLine;
final int newLine;
/// A `\ No newline at end of file` marker: shown verbatim, never numbered.
final bool noNewlineMarker;
}
class PatchHunk {
const PatchHunk({
required this.header,
required this.oldStart,
required this.oldCount,
required this.newStart,
required this.newCount,
required this.lines,
});
final String header;
final int oldStart;
final int oldCount;
final int newStart;
final int newCount;
final List<PatchLine> lines;
}
class ParsedPatch {
const ParsedPatch({
required this.raw,
required this.headerLines,
required this.hunks,
required this.added,
required this.removed,
});
final String raw;
final List<String> headerLines;
final List<PatchHunk> hunks;
final int added;
final int removed;
bool get isEmpty => hunks.isEmpty;
}