Scaffold: Show current Git branch in title (#3834)
This commit is contained in:
parent
844fd98c72
commit
5489b6cc4b
1 changed files with 45 additions and 0 deletions
|
@ -275,6 +275,8 @@ var Scaffold = new function () {
|
||||||
_lastModifiedTime = modifiedTime;
|
_lastModifiedTime = modifiedTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateTitle();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.initImportEditor = function () {
|
this.initImportEditor = function () {
|
||||||
|
@ -637,6 +639,7 @@ var Scaffold = new function () {
|
||||||
|
|
||||||
document.getElementById('textbox-label').focus();
|
document.getElementById('textbox-label').focus();
|
||||||
_showTab('metadata');
|
_showTab('metadata');
|
||||||
|
_updateTitle();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -727,6 +730,7 @@ var Scaffold = new function () {
|
||||||
|
|
||||||
Zotero.Prefs.set('scaffold.lastTranslatorID', translator.translatorID);
|
Zotero.Prefs.set('scaffold.lastTranslatorID', translator.translatorID);
|
||||||
|
|
||||||
|
_updateTitle();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2319,6 +2323,47 @@ var Scaffold = new function () {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function _getGitBranchName() {
|
||||||
|
let gitPath = await Subprocess.pathSearch('git');
|
||||||
|
if (!gitPath) return null;
|
||||||
|
|
||||||
|
let dir = Scaffold_Translators.getDirectory();
|
||||||
|
if (!dir) return null;
|
||||||
|
|
||||||
|
let proc = await Subprocess.call({
|
||||||
|
command: gitPath,
|
||||||
|
arguments: ['rev-parse', '--abbrev-ref', 'HEAD'],
|
||||||
|
workdir: dir,
|
||||||
|
});
|
||||||
|
let output = '';
|
||||||
|
let chunk;
|
||||||
|
while ((chunk = await proc.stdout.readString())) {
|
||||||
|
output += chunk;
|
||||||
|
}
|
||||||
|
return output.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function _updateTitle() {
|
||||||
|
let title = 'Scaffold';
|
||||||
|
|
||||||
|
let label = document.getElementById('textbox-label').value;
|
||||||
|
if (label) {
|
||||||
|
title += ' - ' + label;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let branch = await _getGitBranchName();
|
||||||
|
if (branch) {
|
||||||
|
title += ' (' + branch + ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
Zotero.logError(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.title = title;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("load", function (e) {
|
window.addEventListener("load", function (e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue