Add cache for changes and add change dependencies to log
[?]
Jan 5, 2021, 8:03 PM
HF3NERPZP7TS7STG3WGVSPAYTVYR6IYQ3ZLYZ6EGCDRKNTSHJ2LACDependencies
- [2]
GGYKE3DVEnforce documentation on every Function, Method, and Class - [3]
GNQD74OZAdd pijul.openChange command and text document provider for pijul-change scheme - [4]
WCQM6IOKAdd parsing of Author strings - [5]
ODRMVURUImplement first iteration of file diffing - [6]
L3VOQYAFAdd changelog view to the source control panel - [7]
64J6B76FAdd command to rename channels - [8]
GGYUCHWQUpdate change tooltip in changelog - [9]
ZGMIJNFVCreate pijul.ts for executing commands using the Pijul CLI - [*]
OXW4KMVUAdd QuickDiffProvider - [*]
YUVLBWV3Populate resource groups for unrecorded and untracked changes - [*]
H3GAPFUCAdd pijul.recordAll command
Change contents
- replacement in src/views/changelog.ts at line 26
id: element.hash,// id: element.hash, - replacement in src/views/changelog.ts at line 29
collapsibleState: TreeItemCollapsibleState.None,collapsibleState: TreeItemCollapsibleState.Collapsed, - replacement in src/views/changelog.ts at line 47
// TODO: Implement change dependency trackingreturn null;return await this.repository.getChangeDependencies(element); - edit in src/pijul.ts at line 148
/*** A dictionary for holding a cache of change hashes to avoid recalculating them each time*/private readonly changeCache: Record<string, PijulChange> = {}; - replacement in src/pijul.ts at line 194
return (await this._pijul.exec(this.repositoryRoot, ['change', uri.path], { cancellationToken: token })).stdout;return await this.getChangeToml(uri.path, token); - edit in src/pijul.ts at line 270[12.3032][13.269]
}/*** Get the TOML document describing a specific change* @param hash The hash of the change* @param cancellationToken A token for cancelling the CLI interaction*/async getChangeToml (hash: string, cancellationToken?: CancellationToken): Promise<string> {return (await this._pijul.exec(this.repositoryRoot, ['change', hash], { cancellationToken })).stdout;}/*** Get the Pijul changes which the given change is dependent on* @param change The change to get the dependencies of\ */async getChangeDependencies (change: PijulChange): Promise<PijulChange[]> {const changeToml = await this.getChangeToml(change.hash);const dependencyPattern = /[0-9A-Z]{53}/g;const dependencies: PijulChange[] = [];let match = dependencyPattern.exec(changeToml);while (match) {dependencies.push(this.changeCache[match[0]]);match = dependencyPattern.exec(changeToml);}return dependencies; - replacement in src/pijul.ts at line 384
changes.push(new PijulChange(hash, message.trim(), new PijulChangeAuthor(author), new Date(date)));const cachedChange = this.changeCache[hash];if (cachedChange) {changes.push(cachedChange);} else {const change = new PijulChange(hash, message.trim(), parsePijulChangeAuthor(author), new Date(date));this.changeCache[change.hash] = change;changes.push(change);} - edit in src/pijul.ts at line 524
}/*** Creates a new PijulChangeAuthor by parsing an Author string in a change* @param authorString The full author string, in the format `[Author { name: "GarettWithOneR", full_name: Some("Garett Cooper"), email: Some("garett@garettcooper.com") }]`*/export function parsePijulChangeAuthor (authorString: string): PijulChangeAuthor {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 groupconst [, name, fullName,, email] = match;return new PijulChangeAuthor(name, fullName, email);} else {throw new Error('Failed to parse author string: ' + authorString);} - edit in src/pijul.ts at line 547
public readonly name: string;public readonly fullName?: string;public readonly email?: string; - replacement in src/pijul.ts at line 548
* 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") }]`* Creates a new PijulChangeAuthor instance - replacement in src/pijul.ts at line 550
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);}}constructor (public readonly name: string,public readonly fullName?: string,public readonly email?: string) {}