mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-12 22:24:40 +08:00
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:
@ -28,6 +28,8 @@ class UserInfo {
|
||||
}
|
||||
|
||||
class GitHostRepo {
|
||||
final String name;
|
||||
final String username;
|
||||
final String fullName;
|
||||
final String description;
|
||||
|
||||
@ -44,6 +46,8 @@ class GitHostRepo {
|
||||
final List<String> tags;
|
||||
|
||||
GitHostRepo({
|
||||
@required this.name,
|
||||
@required this.username,
|
||||
@required this.fullName,
|
||||
@required this.description,
|
||||
@required this.cloneUrl,
|
||||
@ -58,6 +62,8 @@ class GitHostRepo {
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'name': name,
|
||||
'username': username,
|
||||
'fullName': fullName,
|
||||
'description': description,
|
||||
'cloneUrl': cloneUrl,
|
||||
|
@ -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'],
|
||||
|
@ -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'],
|
||||
|
Reference in New Issue
Block a user