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 'dart:convert';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
class Collection { class Collection {
...@@ -457,3 +458,15 @@ class EventStoreInstance extends EventStoreBase { ...@@ -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'; ...@@ -8,31 +8,18 @@ import 'overview.dart';
import 'configuration.dart'; import 'configuration.dart';
import 'databaseconnector.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 { Future<void> loadConfiguration() async {
final ConfigurationStoreInstance configuration = ConfigurationStoreInstance(); final ConfigurationStoreInstance configuration = ConfigurationStoreInstance();
final EventStoreInstance event = EventStoreInstance(); final EventStoreInstance event = EventStoreInstance();
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
getGitInfo(); loadGitInfo(); //In oder to display the git commit version.
// Load conf and last event fields from shared preferences to prefill UI // Load conf and last event fields from shared preferences to prefill UI
await configuration.loadFromSharedPrefs(); await configuration.loadFromSharedPrefs();
await event.loadFromSharedPrefs(); await event.loadFromSharedPrefs();
//const storage = FlutterSecureStorage(); //TODO: move login information to secure storage //const storage = FlutterSecureStorage(); //TODO: move login information to secure storage
//Map<String, String> allValues = await storage.readAll(); //Map<String, String> allValues = await storage.readAll();
//print('Secure Storage: ' + allValues.toString()); //print('Secure Storage: ' + allValues.toString());
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mobileeventlog/datamodel.dart';
class Overview extends StatelessWidget { class Overview extends StatelessWidget {
const Overview({Key? key}) : super(key: key); const Overview({Key? key}) : super(key: key);
...@@ -11,14 +12,16 @@ class Overview extends StatelessWidget { ...@@ -11,14 +12,16 @@ class Overview extends StatelessWidget {
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: const <Widget>[ children: <Widget>[
Icon( Icons.copyright_outlined), const Icon( Icons.copyright_outlined),
Text('Alfred Wegener Institute'), const Text('Alfred Wegener Institute'),
Text('Data-Logistics-Support'), const Text('Data-Logistics-Support'),
SizedBox(height: 10), const SizedBox(height: 10),
Text('Maximilian Betz'), const Text('Maximilian Betz'),
SizedBox(height: 30), const SizedBox(height: 30),
Text('o2a-support@awi.de'), const Text('o2a-support@awi.de'),
const SizedBox(height: 30),
Text('Git-Commit-Hash: ' + getGitHash()),
], ],
), ),
actions: <Widget>[ actions: <Widget>[
......
...@@ -71,7 +71,7 @@ flutter: ...@@ -71,7 +71,7 @@ flutter:
- assets/awi_logo.png - assets/awi_logo.png
- .git/HEAD # This file points out the current branch of the project. - .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/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_burr.jpeg
# - images/a_dot_ham.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