Skip to content

Commit

Permalink
Skip org authors, time-sort authors, sort tags to middle
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Dec 13, 2019
1 parent 3d04aba commit 0eefc41
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Netkan/Sources/Github/GithubRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ public class GithubUser
{
[JsonProperty("login")]
public string Login { get; set; }

[JsonProperty("type")]
public string Type { get; set; }
}
}
11 changes: 7 additions & 4 deletions Netkan/Transformers/GithubTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ private Metadata TransformOne(Metadata metadata, JObject json, GithubRef ghRef,
private JToken getAuthors(GithubRepo repo, GithubRelease release)
{
// Start with the user that published the release
var authors = new HashSet<string>() { release.Author };
var authors = new List<string>() { release.Author };
for (GithubRepo r = repo; r != null;)
{
if (r.Owner?.Login != null)
if (r.Owner?.Login != null
&& r.Owner?.Type == userType
&& !authors.Contains(r.Owner.Login))
{
// Add repo owner
authors.Add(r.Owner.Login);
// Prepend repo owner
authors.Insert(0, r.Owner.Login);
}
// Check parent repos
r = r.ParentRepo == null
Expand All @@ -164,5 +166,6 @@ private JToken getAuthors(GithubRepo repo, GithubRelease release)
return authors.Count == 1 ? (JToken)authors.First() : new JArray(authors);
}

private const string userType = "User";
}
}
13 changes: 7 additions & 6 deletions Netkan/Transformers/PropertySortTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ internal sealed class PropertySortTransformer : ITransformer
"spec_version",
"comment",
"identifier",
"$kref",
"$vref",
"name",
"abstract",
"description",
"author",
"license",
"release_status",
"resources",
"$kref",
"$vref",
"version",
"ksp_version",
"ksp_version_min",
"ksp_version_max",
"ksp_version_strict",
"license",
"release_status",
"resources",
"tags",
"localizations",
"provides",
"depends",
Expand All @@ -43,7 +44,7 @@ internal sealed class PropertySortTransformer : ITransformer
"download",
"download_size",
"download_hash",
"download_content_type"
"download_content_type",
}
.Select((str, index) => new {index, str})
.Concat(new[] { new { index = int.MaxValue, str = "x_generated_by"} })
Expand Down

0 comments on commit 0eefc41

Please sign in to comment.