export declare enum DiffType { /** changes to a text file, which may be partially selected for commit */ Text = 0, /** changes to files of a known format, which can be viewed in the app */ Image = 1, /** changes to an unknown file format, which Git is unable to present in a human-friendly format */ Binary = 2, /** change to a repository which is included as a submodule of this repository */ Submodule = 3 } /** indicate what a line in the diff represents */ export declare enum DiffLineType { Context = 0, Add = 1, Delete = 2, Hunk = 3 } export interface ITextDiff { readonly kind: DiffType.Text; /** The unified text diff - including headers and context */ readonly text: string; /** The diff contents organized by hunk - how the git CLI outputs to the caller */ readonly hunks: ReadonlyArray; } export interface IImageDiff { readonly kind: DiffType.Image; /** * The previous image, if the file was modified or deleted * * Will be undefined for an added image */ readonly previous?: Image; /** * The current image, if the file was added or modified * * Will be undefined for a deleted image */ readonly current?: Image; } export interface IBinaryDiff { readonly kind: DiffType.Binary; } /** The union of diff types that can be rendered in Desktop */ export declare type IDiff = ITextDiff | IImageDiff | IBinaryDiff; /** track details related to each line in the diff */ export declare class DiffLine { readonly text: string; readonly type: DiffLineType; readonly oldLineNumber: number | null; readonly newLineNumber: number | null; readonly noTrailingNewLine: boolean; constructor(text: string, type: DiffLineType, oldLineNumber: number | null, newLineNuber: number | null, noTrailingNewLine?: boolean); withNoTrailingNewLine(noTrailingNewLine: boolean): DiffLine; isIncludeableLine(): boolean; } /** details about the start and end of a diff hunk */ export declare class DiffHunkHeader { /** The line in the old (or original) file where this diff hunk starts */ readonly oldStartLine: number; /** The number of lines in the old (or original) file that this diff hunk covers */ readonly oldLineCount: number; /** The line in the new file where this diff hunk starts */ readonly newStartLine: number; /** The number of lines in the new file that this diff hunk covers */ readonly newLineCount: number; constructor(oldStartLine: number, oldLineCount: number, newStartLine: number, newLineCount: number, sectionHeading?: string | null); } /** each diff is made up of a number of hunks */ export declare class DiffHunk { /** details from the diff hunk header about the line start and patch length */ readonly header: DiffHunkHeader; /** the contents - context and changes - of the diff selection */ readonly lines: ReadonlyArray; /** the diff hunk's start position in the overall file diff */ readonly unifiedDiffStart: number; /** the diff hunk's end position in the overall file diff */ readonly unifiedDiffEnd: number; constructor(header: DiffHunkHeader, lines: ReadonlyArray, unifiedDiffStart: number, unifiedDiffEnd: number); } /** * A container for holding an image for display in the application */ export declare class Image { /** * The base64 encoded contents of the image */ readonly contents: string; /** * The data URI media type, so the browser can render the image correctly */ readonly mediaType: string; } export declare class FileSummary { /** * The number of lines added as part of this change. * * If the file is a binary change, this value is undefined. */ readonly added?: number; /** * The number of lines removed as part of this change. * * If the file is a binary change, this value is undefined. */ readonly removed?: number; /** * The path to this change, relative to the submodule root */ readonly path: string; constructor(path: string, added: number | undefined, removed: number | undefined); /** An ID for the file change. */ get id(): string; } /** the contents of a diff generated by Git */ export interface IRawDiff { /** * The plain text contents of the diff header. This contains * everything from the start of the diff up until the first * hunk header starts. Note that this does not include a trailing * newline. */ readonly header: string; /** * The plain text contents of the diff. This contains everything * after the diff header until the last character in the diff. * * Note that this does not include a trailing newline nor does * it include diff 'no newline at end of file' comments. For * no-newline information, consult the DiffLine noTrailingNewLine * property. */ readonly contents: string; /** * Each hunk in the diff with information about start, and end * positions, lines and line statuses. */ readonly hunks: ReadonlyArray; /** * Whether or not the unified diff indicates that the contents * could not be diffed due to one of the versions being binary. */ readonly isBinary: boolean; } export declare enum DiffSelectionType { All = 0, Partial = 1, None = 2 } /** * An immutable, efficient, storage object for tracking selections of indexable * lines. While general purpose by design this is currently used exclusively for * tracking selected lines in modified files in the working directory. * * This class starts out with an initial (or default) selection state, ie * either all lines are selected by default or no lines are selected by default. * * The selection can then be transformed by marking a line or a range of lines * as selected or not selected. Internally the class maintains a list of lines * whose selection state has diverged from the default selection state. */ export declare class DiffSelection { private readonly defaultSelectionType; private readonly divergingLines; private readonly selectableLines; /** * Initialize a new selection instance where either all lines are selected by default * or not lines are selected by default. */ static fromInitialSelection(initialSelection: DiffSelectionType.All | DiffSelectionType.None): DiffSelection; private constructor(); /** Returns a value indicating the computed overall state of the selection */ getSelectionType(): DiffSelectionType; /** Returns a value indicating wether the given line number is selected or not */ isSelected(lineIndex: number): boolean; /** * Returns a value indicating wether the given line number is selectable. * A line not being selectable usually means it's a hunk header or a context * line. */ isSelectable(lineIndex: number): boolean; /** * Returns a copy of this selection instance with the provided * line selection update. * * @param lineIndex The index (line number) of the line which should * be selected or unselected. * * @param selected Whether the given line number should be marked * as selected or not. */ withLineSelection(lineIndex: number, selected: boolean): DiffSelection; /** * Returns a copy of this selection instance with the provided * line selection update. This is similar to the withLineSelection * method except that it allows updating the selection state of * a range of lines at once. Use this if you ever need to modify * the selection state of more than one line at a time as it's * more efficient. * * @param from The line index (inclusive) from where to start * updating the line selection state. * * @param to The number of lines for which to update the * selection state. A value of zero means no lines * are updated and a value of 1 means only the * line given by lineIndex will be updated. * * @param selected Whether the lines should be marked as selected * or not. */ withRangeSelection(from: number, length: number, selected: boolean): DiffSelection; /** * Returns a copy of this selection instance where the selection state * of the specified line has been toggled (inverted). * * @param lineIndex The index (line number) of the line which should * be selected or unselected. */ withToggleLineSelection(lineIndex: number): DiffSelection; /** * Returns a copy of this selection instance with all lines selected. */ withSelectAll(): DiffSelection; /** * Returns a copy of this selection instance with no lines selected. */ withSelectNone(): DiffSelection; /** * Returns a copy of this selection instance with a specified set of * selecable lines. By default a DiffSelection instance allows selecting * all lines (in fact, it has no notion of how many lines exists or what * it is that is being selected). * * If the selection instance lacks a set of selectable lines it can not * supply an accurate value from getSelectionType when the selection of * all lines have diverged from the default state (since it doesn't know * what all lines mean). */ withSelectableLines(selectableLines: Set): DiffSelection; }