Skip to content

Commit

Permalink
Merge #2663 Get license from GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
politas committed Jan 28, 2019
2 parents 58a3bfd + 3b654eb commit 7c8f15a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- [Multiple] Show progress bar while loading registry (#2617 by: HebaruSan; reviewed: politas)
- [Multiple] Add possibility to clone KSP installs and create dummy ones (#2627 by: DasSkelett; reviewed: HebaruSan, politas)
- [ConsoleUI] Allow overriding menu tip in ConsoleUI (#2635 by: HebaruSan; reviewed: DasSkelett, politas)
- [Netkan] Get license from GitHub (#2663 by: HebaruSan; reviewed: politas)

### Bugfixes

Expand Down
9 changes: 9 additions & 0 deletions Netkan/Sources/Github/GithubRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,14 @@ public sealed class GithubRepo

[JsonProperty("homepage")]
public string Homepage { get; set; }

[JsonProperty("license")]
public GithubLicense License { get; set; }
}

public class GithubLicense
{
[JsonProperty("spdx_id")]
public string Id;
}
}
5 changes: 5 additions & 0 deletions Netkan/Transformers/GithubTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public Metadata Transform(Metadata metadata)
if (!string.IsNullOrWhiteSpace(ghRepo.Description))
json.SafeAdd("abstract", ghRepo.Description);

// GitHub says NOASSERTION if it can't figure out the repo's license
if (!string.IsNullOrWhiteSpace(ghRepo.License?.Id)
&& ghRepo.License.Id != "NOASSERTION")
json.SafeAdd("license", ghRepo.License.Id);

if (!string.IsNullOrWhiteSpace(ghRepo.Homepage))
resourcesJson.SafeAdd("homepage", ghRepo.Homepage);

Expand Down
1 change: 1 addition & 0 deletions Spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ For example: `#/ckan/github/pjf/DogeCoinFlag`.
When used, the following fields will be auto-filled if not already present:

- `name`
- `license`
- `abstract`
- `author`
- `version`
Expand Down

0 comments on commit 7c8f15a

Please sign in to comment.