From 7e5dfa03d658d399aa4c50c838d51872024282f1 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Fri, 24 Nov 2023 19:24:19 -0500 Subject: [PATCH] GitHub: Don't infer AppID if many found (#1112) --- lib/app_sources/github.dart | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/app_sources/github.dart b/lib/app_sources/github.dart index 700fa06..2456335 100644 --- a/lib/app_sources/github.dart +++ b/lib/app_sources/github.dart @@ -117,22 +117,23 @@ class GitHub extends AppSource { .decode(body['content'].toString().split('\n').join(''))) .split('\n') .map((e) => e.trim()); - var appId = trimmedLines - .where((l) => - l.startsWith('applicationId "') || - l.startsWith('applicationId \'')) - .first; - appId = appId - .split(appId.startsWith('applicationId "') ? '"' : '\'')[1]; - if (appId.startsWith('\${') && appId.endsWith('}')) { - appId = trimmedLines - .where((l) => l.startsWith( - 'def ${appId.substring(2, appId.length - 1)}')) - .first; - appId = appId.split(appId.contains('"') ? '"' : '\'')[1]; - } - if (appId.isNotEmpty) { + var appIds = trimmedLines.where((l) => + l.startsWith('applicationId "') || + l.startsWith('applicationId \'')); + appIds = appIds.map((appId) => appId + .split(appId.startsWith('applicationId "') ? '"' : '\'')[1]); + appIds = appIds.map((appId) { + if (appId.startsWith('\${') && appId.endsWith('}')) { + appId = trimmedLines + .where((l) => l.startsWith( + 'def ${appId.substring(2, appId.length - 1)}')) + .first; + appId = appId.split(appId.contains('"') ? '"' : '\'')[1]; + } return appId; + }).where((appId) => appId.isNotEmpty); + if (appIds.length == 1) { + return appIds.first; } } catch (err) { LogsProvider().add(