Skip to content

Commit

Permalink
Get license from GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Jan 22, 2019
1 parent c49489b commit 3b654eb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
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 3b654eb

Please sign in to comment.