Skip to content
Snippets Groups Projects
Commit 51ea07b6 authored by Maximilian Betz's avatar Maximilian Betz
Browse files

included git commit hash in version information

parent 9d484a4c
No related branches found
No related tags found
No related merge requests found
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Collection {
......@@ -457,3 +458,15 @@ class EventStoreInstance extends EventStoreBase {
);
}
}
String gitVersionHash = '';
Future<void> loadGitInfo() async {
final commitHash = await rootBundle.loadString('.git/refs/heads/main');
gitVersionHash = commitHash.substring(0,8); //Use the short version
debugPrint("Commit ID: $gitVersionHash");
}
String getGitHash(){
return gitVersionHash;
}
\ No newline at end of file
......@@ -8,31 +8,18 @@ import 'overview.dart';
import 'configuration.dart';
import 'databaseconnector.dart';
Future<String> getGitInfo() async {
final _head = await rootBundle.loadString('.git/HEAD');
final commitId = await rootBundle.loadString('.git/ORIG_HEAD');
final branch = _head.split('/').last;
print("Branch: $branch");
print("Commit ID: $commitId");
return "Branch: $branch, Commit ID: $commitId";
}
Future<void> loadConfiguration() async {
final ConfigurationStoreInstance configuration = ConfigurationStoreInstance();
final EventStoreInstance event = EventStoreInstance();
WidgetsFlutterBinding.ensureInitialized();
getGitInfo();
loadGitInfo(); //In oder to display the git commit version.
// Load conf and last event fields from shared preferences to prefill UI
await configuration.loadFromSharedPrefs();
await event.loadFromSharedPrefs();
//const storage = FlutterSecureStorage(); //TODO: move login information to secure storage
//Map<String, String> allValues = await storage.readAll();
//print('Secure Storage: ' + allValues.toString());
......
import 'package:flutter/material.dart';
import 'package:mobileeventlog/datamodel.dart';
class Overview extends StatelessWidget {
const Overview({Key? key}) : super(key: key);
......@@ -11,14 +12,16 @@ class Overview extends StatelessWidget {
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: const <Widget>[
Icon( Icons.copyright_outlined),
Text('Alfred Wegener Institute'),
Text('Data-Logistics-Support'),
SizedBox(height: 10),
Text('Maximilian Betz'),
SizedBox(height: 30),
Text('o2a-support@awi.de'),
children: <Widget>[
const Icon( Icons.copyright_outlined),
const Text('Alfred Wegener Institute'),
const Text('Data-Logistics-Support'),
const SizedBox(height: 10),
const Text('Maximilian Betz'),
const SizedBox(height: 30),
const Text('o2a-support@awi.de'),
const SizedBox(height: 30),
Text('Git-Commit-Hash: ' + getGitHash()),
],
),
actions: <Widget>[
......
......@@ -71,7 +71,7 @@ flutter:
- assets/awi_logo.png
- .git/HEAD # This file points out the current branch of the project.
- .git/ORIG_HEAD # This file points to the commit id at origin (last commit id of the remote repository).
- .git/refs/heads/
- .git/refs/heads/main
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment