Skip to content

Commit

Permalink
Extend license by spdx id field (#1913)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihrigb committed Aug 20, 2024
1 parent 8cbc183 commit 338de9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit 338de9a

Please sign in to comment.