Use URIs instead of string paths in changelog

[?]
Jan 15, 2021, 9:04 PM
WPIUUBJIWL7MFUHHBHXXRDCWYE6RCJYUHZS524TD2MYX74AOAIEAC

Dependencies

  • [2] J6DDODYY Update views to refresh with the rest of the repository state
  • [3] 7A3NMQ6Q Show altered files instead of dependencies as children of changes in changelog
  • [4] H3GAPFUC Add pijul.recordAll command
  • [5] GNQD74OZ Add pijul.openChange command and text document provider for pijul-change scheme
  • [6] GVFKCLQH Prevent dependencies from appearing multiple times under the same change
  • [7] L3VOQYAF Add changelog view to the source control panel
  • [*] ZGMIJNFV Create pijul.ts for executing commands using the Pijul CLI
  • [*] WCQM6IOK Add parsing of Author strings

Change contents

  • replacement in src/views/changelog.ts at line 1
    [4.24][2.187:278](),[4.84][4.104:156](),[2.278][4.104:156](),[4.104][4.104:156]()
    import { Event, TreeDataProvider, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
    import { PijulChange, Repository } from '../pijul';
    [4.24]
    [4.156]
    import * as path from 'path';
    import { Event, TreeDataProvider, TreeItem, TreeItemCollapsibleState, Uri, workspace } from 'vscode';
    import { PijulChange, PijulFileChange, Repository } from '../pijul';
  • replacement in src/views/changelog.ts at line 9
    [4.288][3.0:87]()
    export class ChangelogViewProvider implements TreeDataProvider<PijulChange | string> {
    [4.288]
    [4.366]
    export class ChangelogViewProvider implements TreeDataProvider<PijulChange | PijulFileChange> {
  • replacement in src/views/changelog.ts at line 23
    [4.596][3.88:167]()
    getTreeItem (element: PijulChange | string): TreeItem | Thenable<TreeItem> {
    [4.596]
    [3.167]
    getTreeItem (element: PijulChange | PijulFileChange): TreeItem | Thenable<TreeItem> {
  • replacement in src/views/changelog.ts at line 40
    [3.818][3.818:910]()
    // It's a string, representing a file path
    // TODO: Use URIs instead of strings
    [3.818]
    [3.910]
    // It's a PijulFileChange
  • replacement in src/views/changelog.ts at line 42
    [3.1007][3.1007:1054]()
    const sections = element.split(/\\|\//);
    [3.1007]
    [3.1054]
    const relativePath = path.relative(workspace.workspaceFolders?.[0]?.uri.path ?? '/', element.path.fsPath);
  • replacement in src/views/changelog.ts at line 44
    [3.1069][3.1069:1169]()
    label: sections[sections.length - 1],
    description: sections.slice(0, -1).join('/'),
    [3.1069]
    [3.1169]
    label: path.basename(relativePath),
    description: path.dirname(relativePath),
  • replacement in src/views/changelog.ts at line 47
    [3.1226][3.1226:1304]()
    contextValue: 'pijulChangedFile'
    // TODO: Command and Tooltip
    [3.1226]
    [3.1304]
    contextValue: 'pijulChangedFile',
    tooltip: `${element.operations.join(', ')} in ${relativePath}`,
    command: {
    command: 'vscode.open',
    title: 'Open Change TOML',
    arguments: [element.path]
    }
  • replacement in src/views/changelog.ts at line 62
    [4.980][3.1320:1432]()
    async getChildren (element?: PijulChange | string): Promise<Array<PijulChange | string> | null | undefined> {
    [4.980]
    [4.1069]
    async getChildren (element?: PijulChange | PijulFileChange): Promise<Array<PijulChange | PijulFileChange> | null | undefined> {
  • replacement in src/pijul.ts at line 309
    [3.1828][3.1828:1894]()
    async getChangeFiles (change: PijulChange): Promise<string[]> {
    [3.1828]
    [3.1894]
    async getChangeFiles (change: PijulChange): Promise<PijulFileChange[]> {
  • replacement in src/pijul.ts at line 312
    [3.2015][3.2015:2057]()
    const files: Set<string> = new Set();
    [3.2015]
    [3.2057]
    const fileOperations: Record<string, Set<string>> = {};
  • replacement in src/pijul.ts at line 316
    [3.2126][3.2126:2153]()
    files.add(match[2]);
    [3.2126]
    [3.2153]
    const [, operation, path] = match;
    if (fileOperations[path]) {
    fileOperations[path].add(operation);
    } else {
    fileOperations[path] = new Set([operation]);
    }
  • replacement in src/pijul.ts at line 325
    [3.2206][3.2206:2229]()
    return [...files];
    [3.2206]
    [4.269]
    // TODO: cache results
    const files: PijulFileChange[] = [];
    for (const path in fileOperations) {
    files.push(new PijulFileChange(createResourceUri(path), [...fileOperations[path]]));
    }
    return files;
  • edit in src/pijul.ts at line 619
    [10.262]
    [4.2674]
    ) {}
    }
    /**
    * Class representing a change that was made to a file
    */
    export class PijulFileChange {
    /**
    * Create a new instance of a pijul file change
    * @param path The path of the file that was changed
    * @param operations The operations that were performed on the file (Edit, Replacement, etc.)
    */
    constructor (
    public readonly path: Uri,
    public readonly operations: string[]