File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed
Filter options
main/java/org/kohsuke/github
test/java/org/kohsuke/github Expand file tree Collapse file tree 2 files changed +11
-15
lines changed
Original file line number Diff line number Diff line change @@ -853,18 +853,20 @@ protected void wrapUp(GHCommitComment[] page) {
853
853
* This is a preview item and subject to change.
854
854
*
855
855
* @throws IOException as usual but also if you don't use the preview connector
856
+ * @return null if there's no license.
856
857
*/
857
858
@ Preview @ Deprecated
858
859
public GHLicense getLicense () throws IOException {
859
- return getLicenseContent_ ().license ;
860
+ GHContentWithLicense lic = getLicenseContent_ ();
861
+ return lic !=null ? lic .license : null ;
860
862
}
861
863
862
864
/**
863
865
* Retrieves the contents of the repository's license file - makes an additional API call
864
866
* <p>
865
867
* This is a preview item and subject to change.
866
868
*
867
- * @return details regarding the license contents
869
+ * @return details regarding the license contents, or null if there's no license.
868
870
* @throws IOException as usual but also if you don't use the preview connector
869
871
*/
870
872
@ Preview @ Deprecated
@@ -874,9 +876,13 @@ public GHContent getLicenseContent() throws IOException {
874
876
875
877
@ Preview @ Deprecated
876
878
private GHContentWithLicense getLicenseContent_ () throws IOException {
877
- return root .retrieve ()
878
- .withHeader ("Accept" ,"application/vnd.github.drax-preview+json" )
879
- .to (getApiTailUrl ("license" ), GHContentWithLicense .class ).wrap (this );
879
+ try {
880
+ return root .retrieve ()
881
+ .withHeader ("Accept" ,"application/vnd.github.drax-preview+json" )
882
+ .to (getApiTailUrl ("license" ), GHContentWithLicense .class ).wrap (this );
883
+ } catch (FileNotFoundException e ) {
884
+ return null ;
885
+ }
880
886
}
881
887
882
888
/**
Original file line number Diff line number Diff line change @@ -89,16 +89,6 @@ public void getLicense() throws IOException {
89
89
assertTrue ("The HTML URL is correct" , license .getHtmlUrl ().equals (new URL ("http://choosealicense.com/licenses/mit/" )));
90
90
}
91
91
92
- /**
93
- * Attempts to list the licenses with a non-preview connection
94
- *
95
- * @throws IOException is expected to be thrown
96
- */
97
- @ Test (expected = IOException .class )
98
- public void ListLicensesWithoutPreviewConnection () throws IOException {
99
- GitHub .connect ().listLicenses ();
100
- }
101
-
102
92
/**
103
93
* Accesses the 'kohsuke/github-api' repo using {@link GitHub#getRepository(String)}
104
94
* and checks that the license is correct
You can’t perform that action at this time.
0 commit comments