36 lines
1.1 KiB
Dart
36 lines
1.1 KiB
Dart
class BuildInfo {
|
|
static const String _date = String.fromEnvironment(
|
|
'IGNIS_BUILD_DATE',
|
|
defaultValue: '',
|
|
);
|
|
static const String _gitSha = String.fromEnvironment(
|
|
'IGNIS_GIT_SHA',
|
|
defaultValue: '',
|
|
);
|
|
|
|
static bool get hasMetadata => _date.isNotEmpty && _gitSha.isNotEmpty;
|
|
|
|
static String get shortSha {
|
|
if (_gitSha.isEmpty) return 'unknown';
|
|
return _gitSha.length <= 7 ? _gitSha : _gitSha.substring(0, 7);
|
|
}
|
|
|
|
static String get formattedDate {
|
|
if (_date.isEmpty) return 'unknown date';
|
|
|
|
final parsed = DateTime.tryParse(_date);
|
|
if (parsed == null) return _date;
|
|
|
|
final utc = parsed.toUtc();
|
|
final year = utc.year.toString().padLeft(4, '0');
|
|
final month = utc.month.toString().padLeft(2, '0');
|
|
final day = utc.day.toString().padLeft(2, '0');
|
|
final hour = utc.hour.toString().padLeft(2, '0');
|
|
final minute = utc.minute.toString().padLeft(2, '0');
|
|
return '$year-$month-$day $hour:$minute UTC';
|
|
}
|
|
|
|
static String get label =>
|
|
hasMetadata ? '$formattedDate · $shortSha' : 'build info unavailable';
|
|
}
|