feat: Show changelogs from the latest to the last used patches version (#2219)

This commit is contained in:
aAbed 2024-10-21 16:02:23 +05:45 committed by GitHub
parent bd96701103
commit daba737ecb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 54 additions and 23 deletions

View file

@ -49,18 +49,24 @@ class GithubAPI {
}
}
Future<String?> getManagerChangelogs() async {
Future<String?> getChangelogs(bool isPatches) async {
final String repoName = isPatches
? _managerAPI.getPatchesRepo()
: _managerAPI.defaultManagerRepo;
try {
final response = await _dioGetSynchronously(
'/repos/${_managerAPI.defaultManagerRepo}/releases?per_page=50',
'/repos/$repoName/releases?per_page=50',
);
final buffer = StringBuffer();
final String currentVersion =
await _managerAPI.getCurrentManagerVersion();
final String version = isPatches
? _managerAPI.getLastUsedPatchesVersion()
: await _managerAPI.getCurrentManagerVersion();
int releases = 0;
for (final release in response.data) {
if (release['tag_name'] == currentVersion) {
if (release['tag_name'] == version) {
if (buffer.isEmpty) {
buffer.writeln(release['body']);
releases++;
}
break;
}
@ -68,6 +74,10 @@ class GithubAPI {
continue;
}
buffer.writeln(release['body']);
releases++;
if (isPatches && releases == 10) {
break;
}
}
return buffer.toString();
} on Exception catch (e) {