Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
fix: regex for Jefit section headers to support decorative hashes
NIHAL T Pc9de2c8a0c7d
diff --git a/lib/services/workout_import.dart b/lib/services/workout_import.dartindex f0b9c74..9592db3 100644--- a/lib/services/workout_import.dart+++ b/lib/services/workout_import.dart@@ -344,13 +344,13 @@ ImportResult _parseStrongLifts(String csv) {}bool _isJefit(String text) =>- RegExp(r'^\s*###\s*EXERCISE LOGS\s*###\s*$', multiLine: true, caseSensitive: false).hasMatch(text);+ RegExp(r'^\s*###\s*EXERCISE LOGS\s*#+\s*$', multiLine: true, caseSensitive: false).hasMatch(text);Map<String, List<List<String>>> _jefitSections(String text) {final lines = <String, List<String>>{};List<String>? current;for (final line in text.replaceFirst('', '').split(RegExp(r'\r?\n'))) {- final m = RegExp(r'^\s*###\s*(.*?)\s*###\s*$').firstMatch(line);+ final m = RegExp(r'^\s*###\s*(.*?)\s*#+\s*$').firstMatch(line);if (m != null) {current = lines.putIfAbsent(m.group(1)!.toLowerCase(), () => []);continue;diff --git a/test/import_test.dart b/test/import_test.dartindex 3e86e6d..3e50115 100644--- a/test/import_test.dart+++ b/test/import_test.dart@@ -261,6 +261,27 @@ void main() {final r = parseImport(text, isLb: true);expect(r.sessions.first.exercises.first.sets.first.weightKg, closeTo(27.22, 0.05));});++ test('recognises section headings with decorative hashes', () {+ const csv = '''+ ### WORKOUT SESSIONS #################################+ _id,starttime,total_time+ 7,1709661600,3600++ ### EXERCISE LOGS ####################################+ _id,belongsession,ename,mydate,logs+ 1,7,Barbell Bench Press,2024-03-05,"60x10,65x8"+ ''';++ expect(detectFormat(csv), ImportFormat.jefit);++ final result = parseImport(csv);++ expect(result.sessions, hasLength(1));+ expect(result.sessions.first.exercises, hasLength(1));+ expect(result.sessions.first.exercises.first.name, 'Barbell Bench Press');+ expect(result.sessions.first.exercises.first.sets, hasLength(2));+ });});group('openGym', () {