Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show git branch and hash in About dialog #1692

Merged
merged 3 commits into from Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions ElectronClient/app/app.js
Expand Up @@ -512,12 +512,20 @@ class Application extends BaseApplication {

function _showAbout() {
const p = packageInfo;
let gitInfo = '';
if ("git" in p) {
gitInfo = _('Revision') + ": " + p.git.hash + ' (' + p.git.branch + ')';
tessus marked this conversation as resolved.
Show resolved Hide resolved
}
let message = [
p.description,
'',
'Copyright © 2016-2019 Laurent Cozic',
_('%s %s (%s, %s)', p.name, p.version, Setting.value('env'), process.platform),
];
if (!!gitInfo) {
message.push("\n" + gitInfo);
console.info(gitInfo);
}
bridge().showInfoMessageBox(message.join('\n'), {
icon: bridge().electronApp().buildDir() + '/icons/32x32.png',
});
Expand Down
14 changes: 14 additions & 0 deletions ElectronClient/app/compile-package-info.js
@@ -1,4 +1,5 @@
const fs = require('fs-extra');
const execSync = require('child_process').execSync;

// Electron Builder strip off certain important keys from package.json, which we need, in particular build.appId
// so this script is used to preserve the keys that we need.
Expand All @@ -16,6 +17,19 @@ const appId = packageInfo.build.appId;
delete packageInfo.build;
packageInfo.build = { appId: appId };

let branch;
let hash;
try {
branch = execSync('git branch --show-current').toString().trim();
hash = execSync('git log --pretty="%h" -1').toString().trim();
}
catch(err) {
console.warn("Could not get git info", err);
}
if (typeof branch !== 'undefined' && typeof hash !== 'undefined') {
packageInfo.git = { branch: branch, hash: hash };
}

let fileContent = "// Auto-generated by compile-package-info.js\n// Do not change directly\nconst packageInfo = " + JSON.stringify(packageInfo, null, 4) + ';';
fileContent += "\n";
fileContent += "module.exports = packageInfo;";
Expand Down