Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend license by spdx id field #1913

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/java/org/kohsuke/github/GHLicense.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class GHLicense extends GHObject {

/** The name. */
// these fields are always present, even in the short form
protected String key, name;
protected String key, name, spdxId;

/** The featured. */
// the rest is only after populated
Expand Down Expand Up @@ -85,6 +85,15 @@ public String getName() {
return name;
}

/**
* Gets SPDX ID.
*
* @return the spdx id
*/
public String getSpdxId() {
return spdxId;
}

/**
* Featured licenses are bold in the new repository drop-down.
*
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/org/kohsuke/github/GHLicenseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void getLicense() throws IOException {
GHLicense license = gitHub.getLicense(key);
assertThat(license, notNullValue());
assertThat("The name is correct", license.getName(), equalTo("MIT License"));
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT")));
assertThat("The HTML URL is correct",
license.getHtmlUrl(),
equalTo(new URL("http://choosealicense.com/licenses/mit/")));
Expand Down Expand Up @@ -111,6 +112,7 @@ public void checkRepositoryLicense() throws IOException {
GHLicense license = repo.getLicense();
assertThat("The license is populated", license, notNullValue());
assertThat("The key is correct", license.getKey(), equalTo("mit"));
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT")));
assertThat("The name is correct", license.getName(), equalTo("MIT License"));
assertThat("The URL is correct",
license.getUrl(),
Expand All @@ -129,6 +131,7 @@ public void checkRepositoryLicenseAtom() throws IOException {
GHLicense license = repo.getLicense();
assertThat("The license is populated", license, notNullValue());
assertThat("The key is correct", license.getKey(), equalTo("mit"));
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT")));
assertThat("The name is correct", license.getName(), equalTo("MIT License"));
assertThat("The URL is correct",
license.getUrl(),
Expand All @@ -148,6 +151,7 @@ public void checkRepositoryLicensePomes() throws IOException {
GHLicense license = repo.getLicense();
assertThat("The license is populated", license, notNullValue());
assertThat("The key is correct", license.getKey(), equalTo("apache-2.0"));
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("Apache-2.0")));
assertThat("The name is correct", license.getName(), equalTo("Apache License 2.0"));
assertThat("The URL is correct",
license.getUrl(),
Expand Down Expand Up @@ -181,6 +185,7 @@ public void checkRepositoryFullLicense() throws IOException {
GHLicense license = repo.getLicense();
assertThat("The license is populated", license, notNullValue());
assertThat("The key is correct", license.getKey(), equalTo("mit"));
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT")));
assertThat("The name is correct", license.getName(), equalTo("MIT License"));
assertThat("The URL is correct",
license.getUrl(),
Expand Down