Add parsing of Author strings

[?]
Jan 4, 2021, 10:45 PM
WCQM6IOKVTDHAVVFMQKGILO4TMKC5L636AR2Q7IT5UXUHUI7XG5AC

Dependencies

  • [2] L3VOQYAF Add changelog view to the source control panel
  • [3] H6KYVQ2Q Add a class to represent resources
  • [4] L44OILGK Add reset command to resource state context menu
  • [*] ZGMIJNFV Create pijul.ts for executing commands using the Pijul CLI

Change contents

  • replacement in src/views/changelog.ts at line 25
    [2.733][2.733:766]()
    description: element.hash,
    [2.733]
    [2.766]
    description: `${element.author.name}, ${element.date.toISOString()}`,
  • replacement in src/pijul.ts at line 331
    [2.2163][2.2163:2236]()
    changes.push(new PijulChange(hash, message.trim(), author, date));
    [2.2163]
    [2.2236]
    changes.push(new PijulChange(hash, message.trim(), new PijulChangeAuthor(author), new Date(date)));
  • replacement in src/pijul.ts at line 445
    [2.2605][2.2605:2674]()
    public readonly author: string,
    public readonly date: string
    [2.2605]
    [2.2674]
    public readonly author: PijulChangeAuthor,
    public readonly date: Date
  • edit in src/pijul.ts at line 448
    [2.2681]
    [6.7479]
    }
    /**
    * Class representing the Author of a change
    * TODO: Handle multiple authors
    */
    export class PijulChangeAuthor {
    public readonly name: string;
    public readonly fullName?: string;
    public readonly email?: string;
    /**
    * Creates a new PijulChangeAuthor by parsing the Author string in the change
    * @param authorString The full author string, in the format `[Author { name: "GarettWithOneR", full_name: Some("Garett Cooper"), email: Some("garett@garettcooper.com") }]`
    */
    constructor (authorString: string) {
    const parsePattern = /Author\s\{\sname:\s"([^"]*)",\sfull_name:\s(?:Some\("([^"]*)"\)|(None)),\semail:\s(?:Some\("([^"]*)"\)|(None))\s\}/g;
    const match = parsePattern.exec(authorString);
    if (match != null) {
    // The 4th match needs to be skipped, as it is the (None) capture group
    [, this.name, this.fullName,, this.email] = match;
    if (this.fullName === 'None') {
    this.fullName = undefined;
    }
    if (this.email === 'None') {
    this.fullName = undefined;
    }
    } else {
    throw new Error('Failed to parse author string: ' + authorString);
    }
    }