MOBILE-2607 settings: Display last commit in about page

main
dpalou 2018-09-19 14:19:57 +02:00
parent a6b6d28d40
commit b1ffb5237d
4 changed files with 63 additions and 47 deletions

View File

@ -9,6 +9,7 @@ var gulp = require('gulp'),
flatten = require('gulp-flatten'),
npmPath = require('path'),
File = gutil.File,
exec = require('child_process').exec,
license = '' +
'// (C) Copyright 2015 Martin Dougiamas\n' +
'//\n' +
@ -75,7 +76,8 @@ function treatMergedData(data) {
var mergedOrdered = {};
for (var filepath in data) {
var pathSplit = filepath.split('/');
var pathSplit = filepath.split('/'),
prefix;
pathSplit.pop();
@ -230,12 +232,21 @@ gulp.task('lang', function(done) {
// Convert config.json into a TypeScript class.
gulp.task('config', function(done) {
// Get the last commit.
exec('git log -1 --pretty=format:"%H"', function (err, commit, stderr) {
if (err) {
console.error('An error occurred while getting the last commit: ' + err);
} else if (stderr) {
console.error('An error occurred while getting the last commit: ' + stderr);
}
gulp.src(paths.config)
.pipe(through(function(file) {
// Convert the contents of the file into a TypeScript class.
// Disable the rule variable-name in the file.
var config = JSON.parse(file.contents.toString()),
contents = license + '// tslint:disable: variable-name\n' + 'export class CoreConfigConstants {\n';
contents = license + '// tslint:disable: variable-name\n' + 'export class CoreConfigConstants {\n',
that = this;
for (var key in config) {
var value = config[key];
@ -269,8 +280,9 @@ gulp.task('config', function(done) {
contents += ' static ' + key + ' = ' + value + ';\n';
}
// Add compilation time.
// Add compilation info.
contents += ' static compilationtime = ' + Date.now() + ';\n';
contents += ' static lastcommit = \'' + commit + '\';\n';
contents += '}\n';
@ -280,6 +292,7 @@ gulp.task('config', function(done) {
.pipe(rename('configconstants.ts'))
.pipe(gulp.dest(paths.src))
.on('end', done);
});
});
gulp.task('default', gulp.parallel('lang', 'config'));

View File

@ -3,7 +3,7 @@
"appready": "App ready",
"cannotsyncoffline": "Cannot synchronise offline.",
"cannotsyncwithoutwifi": "Cannot synchronise because the current settings only allow to synchronise when connected to Wi-Fi. Please connect to a Wi-Fi network.",
"compilationtime": "Compilation time",
"compilationinfo": "Compilation info",
"cordovadevicemodel": "Cordova device model",
"cordovadeviceosversion": "Cordova device OS version",
"cordovadeviceplatform": "Cordova device platform",

View File

@ -36,9 +36,10 @@
<h2>{{ 'core.settings.versioncode' | translate}}</h2>
<p>{{ versionCode }}</p>
</ion-item>
<ion-item text-wrap *ngIf="compilationTime">
<h2>{{ 'core.settings.compilationtime' | translate }}</h2>
<p>{{ compilationTime | coreFormatDate: "LLL Z" }}</p>
<ion-item text-wrap *ngIf="compilationTime || lastCommit">
<h2>{{ 'core.settings.compilationinfo' | translate }}</h2>
<p *ngIf="compilationTime">{{ compilationTime | coreFormatDate: "LLL Z" }}</p>
<p *ngIf="lastCommit">{{ lastCommit }}</p>
</ion-item>
<ion-item text-wrap *ngIf="fileSystemRoot">
<h2>{{ 'core.settings.filesystemroot' | translate}}</h2>

View File

@ -37,6 +37,7 @@ export class CoreSettingsAboutPage {
versionName: string;
versionCode: number;
compilationTime: number;
lastCommit: string;
privacyPolicy: string;
navigator: Navigator;
locationHref: string;
@ -63,6 +64,7 @@ export class CoreSettingsAboutPage {
this.versionName = CoreConfigConstants.versionname;
this.versionCode = CoreConfigConstants.versioncode;
this.compilationTime = CoreConfigConstants.compilationtime;
this.lastCommit = CoreConfigConstants.lastcommit;
// Calculate the privacy policy to use.
this.privacyPolicy = currentSite.getStoredConfig('tool_mobile_apppolicy') || currentSite.getStoredConfig('sitepolicy') ||