Skip to content

Commit 338de9a

Browse files
authored
Extend license by spdx id field (#1913)
1 parent 8cbc183 commit 338de9a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/java/org/kohsuke/github/GHLicense.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class GHLicense extends GHObject {
4949

5050
/** The name. */
5151
// these fields are always present, even in the short form
52-
protected String key, name;
52+
protected String key, name, spdxId;
5353

5454
/** The featured. */
5555
// the rest is only after populated
@@ -85,6 +85,15 @@ public String getName() {
8585
return name;
8686
}
8787

88+
/**
89+
* Gets SPDX ID.
90+
*
91+
* @return the spdx id
92+
*/
93+
public String getSpdxId() {
94+
return spdxId;
95+
}
96+
8897
/**
8998
* Featured licenses are bold in the new repository drop-down.
9099
*

src/test/java/org/kohsuke/github/GHLicenseTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public void getLicense() throws IOException {
8383
GHLicense license = gitHub.getLicense(key);
8484
assertThat(license, notNullValue());
8585
assertThat("The name is correct", license.getName(), equalTo("MIT License"));
86+
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT")));
8687
assertThat("The HTML URL is correct",
8788
license.getHtmlUrl(),
8889
equalTo(new URL("http://choosealicense.com/licenses/mit/")));
@@ -111,6 +112,7 @@ public void checkRepositoryLicense() throws IOException {
111112
GHLicense license = repo.getLicense();
112113
assertThat("The license is populated", license, notNullValue());
113114
assertThat("The key is correct", license.getKey(), equalTo("mit"));
115+
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT")));
114116
assertThat("The name is correct", license.getName(), equalTo("MIT License"));
115117
assertThat("The URL is correct",
116118
license.getUrl(),
@@ -129,6 +131,7 @@ public void checkRepositoryLicenseAtom() throws IOException {
129131
GHLicense license = repo.getLicense();
130132
assertThat("The license is populated", license, notNullValue());
131133
assertThat("The key is correct", license.getKey(), equalTo("mit"));
134+
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT")));
132135
assertThat("The name is correct", license.getName(), equalTo("MIT License"));
133136
assertThat("The URL is correct",
134137
license.getUrl(),
@@ -148,6 +151,7 @@ public void checkRepositoryLicensePomes() throws IOException {
148151
GHLicense license = repo.getLicense();
149152
assertThat("The license is populated", license, notNullValue());
150153
assertThat("The key is correct", license.getKey(), equalTo("apache-2.0"));
154+
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("Apache-2.0")));
151155
assertThat("The name is correct", license.getName(), equalTo("Apache License 2.0"));
152156
assertThat("The URL is correct",
153157
license.getUrl(),
@@ -181,6 +185,7 @@ public void checkRepositoryFullLicense() throws IOException {
181185
GHLicense license = repo.getLicense();
182186
assertThat("The license is populated", license, notNullValue());
183187
assertThat("The key is correct", license.getKey(), equalTo("mit"));
188+
assertThat("The SPDX ID is correct", license.getSpdxId(), is(equalTo("MIT")));
184189
assertThat("The name is correct", license.getName(), equalTo("MIT License"));
185190
assertThat("The URL is correct",
186191
license.getUrl(),

0 commit comments

Comments
 (0)