Skip to content

Commit

Permalink
Edo fullLog Blame implementation
Browse files Browse the repository at this point in the history
- blame implemented on fullLog option, which gives blame from the whole map
  • Loading branch information
danko committed Dec 17, 2019
1 parent 263eb66 commit 5a998b3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
26 changes: 26 additions & 0 deletions src/api/EdoCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,32 @@ export class EdoCache {
return logDetails;
}

public static mergeLogContentPrevious(logPrev: Buffer, logNew: Buffer, vvll: string) {
let prev: string[] = logPrev.toString().split('\n');
let cur: string[] = logNew.toString().split('\n');
let output: string[] = [];
let foundDetail: boolean = false;
let prevCounter: number = 0;
for (const line of cur) {
if (!foundDetail && line[2] == ' ') {
if (line.slice(3, 7) == vvll) {
foundDetail = true;
}
} else if (line[2] == '+') {
// if (line.slice(3, 7) > vvll) continue;
if (line.slice(3, 7) == vvll) {
if (line[7] != '-') {
output.push(prev[prevCounter]);
}
prevCounter++;
continue;
} else if (line[7] == '-') continue;
output.push(line.slice(3, 7) + " " + line.slice(13));
}
}
return Buffer.from(output.join('\n'));
}

public static extractLogContent(logBuf: Buffer, vvll: string, details: boolean = false) {
let lines: string[] = logBuf.toString().split('\n');
let output: string[] = [];
Expand Down
34 changes: 28 additions & 6 deletions src/cli/EdoShow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,41 @@ To show content of log, specify object with stage and back reference (remote/STA

// do blame with fullLogs
} else {
let finalOutput: string | null = null;
let finalOutput: Buffer | null = null;
let lastVVLL: string | null = null;
for (const stage of map) {
if (!isNullOrUndefined(vvllStage[stage])) {
const out = (await EdoCache.getLogsContent(`remote/${stage}`, file, vvllStage[stage], true)).toString(); //.split('\n');
if (finalOutput != null) {

// const out = (await EdoCache.getLogsContent(`remote/${stage}`, file, vvllStage[stage], true)).toString(); //.split('\n');
if (finalOutput != null && !isNullOrUndefined(lastVVLL)) {
// console.log(`running for other stage ${stage}`);
const index = await EdoCache.readIndex(`remote/${stage}`);
const buf: Buffer = await EdoCache.getSha1Object(index.elem[file][3], EdoCache.OBJ_LOGS);
// const newLog = EdoCache.extractLogContent(buf, vvllStage[stage], true);
finalOutput = EdoCache.mergeLogContentPrevious(finalOutput, buf, lastVVLL);
lastVVLL = vvllStage[stage];
} else {
finalOutput = out;
finalOutput = await EdoCache.getLogsContent(`remote/${stage}`, file, vvllStage[stage], true);
lastVVLL = vvllStage[stage];
}
}

}
console.log(finalOutput);
if (finalOutput != null) {
const out = finalOutput.toString().split('\n');
for (const line of out) {
const lineV = line.substr(0, 4);
const pref = logsOut[lineV];
let prefix = '';
if (pref) {
// [ vvll, user, date, ccid, comment ];
prefix = pref.slice(1).join(' ');
}
console.log(`(${prefix}) ${line.substr(5)}`);
}
} else {
console.error(`no logs for file ${file}!`);
process.exit(1);
}
return;
// for (const line of out) {
// const lineV = line.substr(0, 4);
Expand Down

0 comments on commit 5a998b3

Please sign in to comment.