-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #4318 Exclude release author bots from authors list
- Loading branch information
Showing
8 changed files
with
191 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,31 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
|
||
using Newtonsoft.Json.Linq; | ||
using Newtonsoft.Json; | ||
|
||
using CKAN.Versioning; | ||
|
||
namespace CKAN.NetKAN.Sources.Github | ||
{ | ||
internal sealed class GithubRelease | ||
public sealed class GithubRelease | ||
{ | ||
public readonly string? Author; | ||
public readonly ModuleVersion? Tag; | ||
public readonly List<GithubReleaseAsset>? Assets; | ||
public readonly bool PreRelease; | ||
public readonly DateTime? PublishedAt; | ||
|
||
public GithubRelease(GithubRef reference, JToken json) | ||
{ | ||
PreRelease = (bool?)json["prerelease"] ?? false; | ||
Tag = (string?)json["tag_name"] is string s ? new ModuleVersion(s) : null; | ||
if (Tag == null) | ||
{ | ||
throw new Kraken("GitHub release missing tag!"); | ||
} | ||
Author = (string?)json["author"]?["login"]; | ||
PublishedAt = (DateTime?)json["published_at"]; | ||
Assets = reference.UseSourceArchive | ||
&& (string?)json["zipball_url"] is string sourceZIP | ||
? new List<GithubReleaseAsset> { | ||
new GithubReleaseAsset(Tag.ToString(), new Uri(sourceZIP), PublishedAt), | ||
} | ||
: (JArray?)json["assets"] is JArray assets | ||
&& reference.Filter != null | ||
? assets.Select(asset => (string?)asset["name"] is string name | ||
&& reference.Filter.IsMatch(name) | ||
&& (string?)asset["browser_download_url"] is string url | ||
&& (DateTime?)asset["updated_at"] is DateTime updated | ||
? new GithubReleaseAsset(name, new Uri(url), updated) | ||
: null) | ||
.OfType<GithubReleaseAsset>() | ||
.ToList() | ||
: new List<GithubReleaseAsset>(); | ||
} | ||
|
||
public GithubRelease(string author, ModuleVersion tag, List<GithubReleaseAsset> assets) | ||
{ | ||
Author = author; | ||
Tag = tag; | ||
Assets = assets; | ||
} | ||
[JsonProperty("author")] | ||
public GithubUser? Author { get; set; } | ||
|
||
[JsonProperty("tag_name")] | ||
public ModuleVersion? Tag { get; set; } | ||
|
||
[JsonProperty("assets")] | ||
public GithubReleaseAsset[]? Assets { get; set; } | ||
|
||
[JsonProperty("zipball_url")] | ||
public Uri? SourceArchive { get; set; } | ||
|
||
[JsonProperty("published_at")] | ||
public DateTime? PublishedAt { get; set; } | ||
|
||
[JsonProperty("prerelease")] | ||
[DefaultValue(false)] | ||
public bool PreRelease { get; set; } = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
using System; | ||
|
||
using Newtonsoft.Json; | ||
|
||
namespace CKAN.NetKAN.Sources.Github | ||
{ | ||
public sealed class GithubReleaseAsset | ||
{ | ||
public string Name { get; } | ||
public Uri Download { get; } | ||
public DateTime? Updated { get; } | ||
[JsonProperty("name")] | ||
public string? Name { get; set; } | ||
|
||
[JsonProperty("browser_download_url")] | ||
public Uri? Download { get; set; } | ||
|
||
[JsonProperty("updated_at")] | ||
public DateTime? Updated { get; set; } | ||
|
||
public GithubReleaseAsset(string name, Uri download, DateTime? updated) | ||
{ | ||
Name = name; | ||
Download = download; | ||
Updated = updated; | ||
} | ||
[JsonProperty("uploader")] | ||
public GithubUser? Uploader { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.