Implement first iteration of file diffing

[?]
Dec 30, 2020, 3:02 AM
ODRMVURU4WGZNYNFTK4ZR6YVA4V4R6EL2OK3PJLYE2HJJEMNISSQC

Dependencies

  • [2] VP6KWIRT Add inline icons for commands on SCM view
  • [3] IBRKAWNM Moved utility modules into their own folder
  • [4] 6ONRFFRG First pass of file decorations
  • [5] EJYTCVNQ Add stderr to error message when pijul CLI command fails
  • [6] H6KYVQ2Q Add a class to represent resources
  • [7] FAMBRMO7 Add command to open file to source control resources
  • [8] ZGMIJNFV Create pijul.ts for executing commands using the Pijul CLI
  • [9] YUVLBWV3 Populate resource groups for unrecorded and untracked changes
  • [*] B4SKYP3Y Add repository model and add steps to initialize it
  • [*] ILH3GIVT Add command centre and refresh/init commands
  • [*] 6H4B4UJQ Add commands to open repo and global pijul configuration files
  • [*] NCBEWRYE Initialize Repository

Change contents

  • edit in src/repository.ts at line 92
    [3.241]
    [3.241]
    this.disposables.push(workspace.registerTextDocumentContentProvider('pijul', this.repository));
  • replacement in src/pijul.ts at line 5
    [3.692][3.692:766]()
    import { CancellationToken, TextDocument, Uri, workspace } from 'vscode';
    [3.692]
    [3.5832]
    import { CancellationToken, TextDocument, TextDocumentContentProvider, Uri, workspace } from 'vscode';
  • replacement in src/pijul.ts at line 135
    [3.4343][3.4343:4369]()
    export class Repository {
    [3.4343]
    [3.4369]
    export class Repository implements TextDocumentContentProvider {
  • edit in src/pijul.ts at line 150
    [3.834]
    [3.834]
    * Implementation of the TextDocumentContentProvider, uses the `pijul reset <file> --dry-run` CLI command
    * to get the last recorded version of the file at the given URI, which VS Code can open as a text document.
    * @param uri The URI, with scheme 'pijul', which will be used to retrieve the last recorded version of the file
    * @param token A cancellation token for stopping the asynchronous child process execution
    */
    async provideTextDocumentContent (uri: Uri, token: CancellationToken): Promise<string> {
    // return stdout, which is the last recorded version of the file
    return (await this._pijul.exec(this.repositoryRoot, ['reset', uri.path, '--dry-run'], { cancellationToken: token })).stdout;
    }
    /**
  • edit in src/commands.ts at line 203
    [3.348]
    [13.241]
    }
    }
    /**
    * Open a diff comparison between a file and its last recorded version
    * @param resourceStates The resources to open
    */
    @command('pijul.openDiff')
    async openDiff (...resourceStates: SourceControlResourceState[]): Promise<void> {
    for await (const resourceState of resourceStates) {
    const pijulUri = resourceState.resourceUri.with({ scheme: 'pijul' });
    await commands.executeCommand('vscode.diff', pijulUri, resourceState.resourceUri);
  • edit in package.json at line 81
    [13.1175]
    [13.1175]
    "command": "pijul.openDiff",
    "title": "Open Diff",
    "category": "Pijul",
    "icon": "$(diff)"
    },
    {
  • replacement in package.json at line 198
    [2.1168][2.1168:1175]()
    },
    [2.1168]
    [2.1175]
    },
  • edit in package.json at line 202
    [2.1252]
    [2.1252]
    "group": "first"
    },
    {
    "command": "pijul.openDiff",
    "when": "scmProvider == pijul && scmResourceGroup == changed",