From 13e10692b16938a801db7ee8874c6060cac2ed33 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Fri, 25 Aug 2023 20:40:35 -0400 Subject: [PATCH] 'Verify latest tag' toggle (#798, #740) --- assets/translations/bs.json | 1 + assets/translations/de.json | 1 + assets/translations/en.json | 1 + assets/translations/es.json | 1 + assets/translations/fa.json | 1 + assets/translations/fr.json | 1 + assets/translations/hu.json | 1 + assets/translations/it.json | 1 + assets/translations/ja.json | 1 + assets/translations/pl.json | 1 + assets/translations/ru.json | 1 + assets/translations/zh.json | 1 + lib/app_sources/github.dart | 30 ++++++++++++++++++++++++++++++ 13 files changed, 42 insertions(+) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index cd14a19..830a3ac 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -246,6 +246,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "Želite li ukloniti aplikaciju?", "other": "Želite li ukloniti aplikacije?" diff --git a/assets/translations/de.json b/assets/translations/de.json index 9227e9f..cd31e8a 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -246,6 +246,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "App entfernen?", "other": "Apps entfernen?" diff --git a/assets/translations/en.json b/assets/translations/en.json index 165b4ff..e3a7684 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -247,6 +247,7 @@ "enableBackgroundUpdates": "Enable background updates", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index bbed509..afe6e5e 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -246,6 +246,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "¿Eliminar Aplicación?", "other": "¿Eliminar Aplicaciones?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index 93caa25..5d7e754 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -246,6 +246,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index bfbbfcc..2ab4bb8 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -246,6 +246,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index 5c5fd49..d30c802 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -245,6 +245,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "Eltávolítja az alkalmazást?", "other": "Eltávolítja az alkalmazást?" diff --git a/assets/translations/it.json b/assets/translations/it.json index 14586d4..b4d0359 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -246,6 +246,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "Rimuovere l'app?", "other": "Rimuovere le app?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index 386a512..7c2e285 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -246,6 +246,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/pl.json b/assets/translations/pl.json index 327e720..8b4ed79 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -250,6 +250,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "Usunąć aplikację?", "other": "Usunąć aplikacje?" diff --git a/assets/translations/ru.json b/assets/translations/ru.json index e8a2507..703f057 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -246,6 +246,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "Удалить приложение?", "other": "Удалить приложения?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index eac5e3e..48cf7b4 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -246,6 +246,7 @@ "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", + "verifyLatestTag": "Verify the 'latest' tag", "removeAppQuestion": { "one": "是否删除应用?", "other": "是否删除应用?" diff --git a/lib/app_sources/github.dart b/lib/app_sources/github.dart index 608c31c..0b2f2c9 100644 --- a/lib/app_sources/github.dart +++ b/lib/app_sources/github.dart @@ -85,6 +85,10 @@ class GitHub extends AppSource { return regExValidator(value); } ]) + ], + [ + GeneratedFormSwitch('verifyLatestTag', + label: tr('verifyLatestTag'), defaultValue: false) ] ]; @@ -212,6 +216,21 @@ class GitHub extends AppSource { true ? additionalSettings['filterReleaseNotesByRegEx'] : null; + bool verifyLatestTag = additionalSettings['verifyLatestTag'] == true; + String? latestTag; + if (verifyLatestTag) { + var temp = requestUrl.split('?'); + Response res = await sourceRequest( + '${temp[0]}/latest${temp.length > 1 ? '?${temp.sublist(1).join('?')}' : ''}'); + if (res.statusCode != 200) { + if (onHttpErrorCode != null) { + onHttpErrorCode(res); + } + throw getObtainiumHttpError(res); + } + var jsres = jsonDecode(res.body); + latestTag = jsres['tag_name'] ?? jsres['name']; + } Response res = await sourceRequest(requestUrl); if (res.statusCode == 200) { var releases = jsonDecode(res.body) as List; @@ -258,6 +277,17 @@ class GitHub extends AppSource { } } }); + if (latestTag != null && + releases.isNotEmpty && + latestTag != + (releases[releases.length - 1]['tag_name'] ?? + releases[0]['name'])) { + var ind = releases.indexWhere( + (element) => latestTag == (element['tag_name'] ?? element['name'])); + if (ind >= 0) { + releases.add(releases.removeAt(ind)); + } + } releases = releases.reversed.toList(); dynamic targetRelease; var prerrelsSkipped = 0;