Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ function createDownloadButtons(file: ModifiedFile) {
if (file.new || !file.deleted) {
const btn = document.createElement('button');
btn.classList.add('download-button', 'button-50');
btn.style.marginRight = '5px';
btn.textContent = 'Show new';
btn.addEventListener('click', () => onDownload(file, 'new'));
buttons.push(btn);
Expand Down
23 changes: 17 additions & 6 deletions src/scm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ abstract class BaseScmAdapter {
});
}

private calcShortHash(sha: string): string {
return sha.substring(0, 8);
}

private async doDownloadFile(
url: string,
type: 'raw' | 'json',
Expand Down Expand Up @@ -245,12 +249,15 @@ abstract class BaseScmAdapter {
file.download.old,
file.download.type,
file.filename,
'_old',
`.${this.calcShortHash(file.shaOld)}.old`,
token,
file.shaOld,
);
} else {
oldFile = await this.downloadDummy(file.filename, '_old');
oldFile = await this.downloadDummy(
file.filename,
`.${this.calcShortHash(file.shaOld)}.old`,
);
}

let newFile = '';
Expand All @@ -259,12 +266,15 @@ abstract class BaseScmAdapter {
file.download.new,
file.download.type,
file.filename,
'_new',
`.${this.calcShortHash(file.shaNew)}.new`,
token,
file.shaNew,
);
} else {
newFile = await this.downloadDummy(file.filename, '_new');
newFile = await this.downloadDummy(
file.filename,
`.${this.calcShortHash(file.shaNew)}.new`,
);
}

const protocolUrl = encodeURI(
Expand All @@ -274,13 +284,14 @@ abstract class BaseScmAdapter {
}

async downloadFile(file: ModifiedFile, what: 'old' | 'new', token: string) {
const sha = what == 'old' ? file.shaOld : file.shaNew;
const theFile = await this.doDownloadFile(
file.download[what],
file.download.type,
file.filename,
what == 'old' ? file.filenameOld : '_' + what,
`.${this.calcShortHash(sha)}.${what}`,
token,
what == 'old' ? file.shaOld : file.shaNew,
sha,
);
const protocolUrl = encodeURI(`tracetronic:///${theFile}`);
await browser.tabs.update({ url: protocolUrl });
Expand Down