HF3NERPZP7TS7STG3WGVSPAYTVYR6IYQ3ZLYZ6EGCDRKNTSHJ2LAC
GGYKE3DVQ5DTJGVHVAUTRF2BWLGNGKUGZMKEPOVEXAND3ITBWE5AC
GNQD74OZ56J2R23GVUGFP3G5KVML2KDZ4OUZK6SVLSM7HVO2WOCAC
L3VOQYAF3HCAFWJ7QFULL54WUZ35B4K3MWU5YDRW7R4VTXSDWJUQC
WCQM6IOKVTDHAVVFMQKGILO4TMKC5L636AR2Q7IT5UXUHUI7XG5AC
OXW4KMVURSBSSHOFK4DADOGVBRCURJ6EFFU6BBZE6IQC7BUBR5IQC
ZGMIJNFVDK7R6AF56FNCA23W5KV3HVBUBPTWMLQADCEPB3MOPELQC
YUVLBWV3UDNQG63DMTQQOBBL4WMK2J7ODPIZ5337X5PDBZYFQO6AC
H3GAPFUC4TCMSLC3O4LUNQNHRANRNVIOQJRTZT4XQ3AUXFHTW4CAC
}
/**
* 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;
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);
}
}
/**
* 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 group
const [, name, fullName,, email] = match;
return new PijulChangeAuthor(name, fullName, email);
} else {
throw new Error('Failed to parse author string: ' + authorString);
}
* 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
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
) {}