Add parsing of Author strings
[?]
Jan 4, 2021, 10:45 PM
WCQM6IOKVTDHAVVFMQKGILO4TMKC5L636AR2Q7IT5UXUHUI7XG5ACDependencies
- [2]
L3VOQYAFAdd changelog view to the source control panel - [3]
H6KYVQ2QAdd a class to represent resources - [4]
L44OILGKAdd reset command to resource state context menu - [*]
ZGMIJNFVCreate pijul.ts for executing commands using the Pijul CLI
Change contents
- replacement in src/views/changelog.ts at line 25
description: element.hash,description: `${element.author.name}, ${element.date.toISOString()}`, - replacement in src/pijul.ts at line 331
changes.push(new PijulChange(hash, message.trim(), author, date));changes.push(new PijulChange(hash, message.trim(), new PijulChangeAuthor(author), new Date(date))); - replacement in src/pijul.ts at line 445
public readonly author: string,public readonly date: stringpublic 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);}}