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

@ -217,8 +217,19 @@ class GitLab implements GitHost {
tags = tagList.map((e) => e.toString()).toList();
}
var fullName = parsedJson['path_with_namespace'].toString();
var namespace = parsedJson['namespace'];
var username = "";
if (namespace != null) {
username = (namespace as Map)["path"];
} else {
username = fullName.split('/').first;
}
return GitHostRepo(
fullName: parsedJson['path_with_namespace'],
name: parsedJson["name"],
username: username,
fullName: fullName,
cloneUrl: parsedJson['ssh_url_to_repo'],
updatedAt: updatedAt,
description: parsedJson['description'],