GitHostRepo: Add name and username

Instead of having to parse this from the fullName. This way the code is
easier to read and it's more reliable.
This commit is contained in:
Vishesh Handa
2020-11-13 15:36:24 +01:00
parent 819702bc6c
commit df78b24542
4 changed files with 36 additions and 13 deletions

View File

@ -226,6 +226,15 @@ class GitHub implements GitHost {
Log.e(e);
}
var licenseMap = parsedJson['license'];
var fullName = parsedJson['full_name'].toString();
var owner = parsedJson['owner'];
var username = "";
if (owner != null) {
username = (owner as Map)["login"];
} else {
username = fullName.split('/').first;
}
/*
print("");
@ -234,7 +243,9 @@ class GitHub implements GitHost {
*/
return GitHostRepo(
fullName: parsedJson['full_name'],
name: parsedJson['name'],
username: username,
fullName: fullName,
cloneUrl: parsedJson['ssh_url'],
updatedAt: updatedAt,
description: parsedJson['description'],