|
38 | 38 | */ |
39 | 39 | class ChangelogCreator { |
40 | 40 |
|
41 | | - private static final int MILESTONE_ID = 117; |
42 | | - private static final String URI_TEMPLATE = "https://api.github.com/repos/spring-projects/spring-hateoas/issues?milestone={id}&state=closed"; |
| 41 | + private static final int MILESTONE_ID = 119; |
| 42 | + private static final String URI_TEMPLATE = "https://api.github.com/repos/spring-projects/spring-hateoas/issues?milestone={id}"; |
43 | 43 |
|
44 | | - public static void main(String... args) { |
| 44 | + public static void main(String... args) { |
45 | 45 |
|
46 | | - /* |
47 | | - * If you run into github rate limiting issues, you can always use a Github Personal Token by adding |
48 | | - * {@code .header(HttpHeaders.AUTHORIZATION, "token your-github-token")} to the webClient call. |
49 | | - */ |
| 46 | + /* |
| 47 | + * If you run into github rate limiting issues, you can always use a Github Personal Token by adding |
| 48 | + * {@code .header(HttpHeaders.AUTHORIZATION, "token your-github-token")} to the webClient call. |
| 49 | + */ |
50 | 50 |
|
51 | | - WebClient webClient = WebClient.create(); |
| 51 | + WebClient webClient = WebClient.create(); |
52 | 52 |
|
53 | | - HttpEntity<String> response = webClient // |
54 | | - .get().uri(URI_TEMPLATE, MILESTONE_ID) // |
55 | | - .exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) // |
56 | | - .block(Duration.ofSeconds(10)); |
| 53 | + HttpEntity<String> response = webClient // |
| 54 | + .get().uri(URI_TEMPLATE, MILESTONE_ID) // |
| 55 | + .exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) // |
| 56 | + .block(Duration.ofSeconds(10)); |
57 | 57 |
|
58 | | - boolean keepChecking = true; |
59 | | - boolean printHeader = true; |
| 58 | + boolean keepChecking = true; |
| 59 | + boolean printHeader = true; |
60 | 60 |
|
61 | | - while (keepChecking) { |
| 61 | + while (keepChecking) { |
62 | 62 |
|
63 | | - readPage(response.getBody(), printHeader); |
64 | | - printHeader = false; |
| 63 | + readPage(response.getBody(), printHeader); |
| 64 | + printHeader = false; |
65 | 65 |
|
66 | | - List<String> linksInHeader = response.getHeaders().get(HttpHeaders.LINK); |
67 | | - Links links = linksInHeader == null ? Links.NONE : Links.parse(linksInHeader.get(0)); |
| 66 | + List<String> linksInHeader = response.getHeaders().get(HttpHeaders.LINK); |
| 67 | + Links links = linksInHeader == null ? Links.NONE : Links.parse(linksInHeader.get(0)); |
68 | 68 |
|
69 | | - if (links.getLink(IanaLinkRelations.NEXT).isPresent()) { |
| 69 | + if (links.getLink(IanaLinkRelations.NEXT).isPresent()) { |
70 | 70 |
|
71 | | - response = webClient // |
72 | | - .get().uri(links.getRequiredLink(IanaLinkRelations.NEXT).expand().getHref()) // |
73 | | - .exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) // |
74 | | - .block(Duration.ofSeconds(10)); |
| 71 | + response = webClient // |
| 72 | + .get().uri(links.getRequiredLink(IanaLinkRelations.NEXT).expand().getHref()) // |
| 73 | + .exchangeToMono(clientResponse -> clientResponse.toEntity(String.class)) // |
| 74 | + .block(Duration.ofSeconds(10)); |
75 | 75 |
|
76 | | - } else { |
77 | | - keepChecking = false; |
78 | | - } |
79 | | - } |
80 | | - } |
| 76 | + } else { |
| 77 | + keepChecking = false; |
| 78 | + } |
| 79 | + } |
| 80 | + } |
81 | 81 |
|
82 | | - private static void readPage(String content, boolean header) { |
| 82 | + private static void readPage(String content, boolean header) { |
83 | 83 |
|
84 | | - JsonPath titlePath = JsonPath.compile("$[*].title"); |
85 | | - JsonPath idPath = JsonPath.compile("$[*].number"); |
| 84 | + JsonPath titlePath = JsonPath.compile("$[*].title"); |
| 85 | + JsonPath idPath = JsonPath.compile("$[*].number"); |
86 | 86 |
|
87 | | - JSONArray titles = titlePath.read(content); |
88 | | - Iterator<Object> ids = ((JSONArray) idPath.read(content)).iterator(); |
| 87 | + JSONArray titles = titlePath.read(content); |
| 88 | + Iterator<Object> ids = ((JSONArray) idPath.read(content)).iterator(); |
89 | 89 |
|
90 | | - if (header) { |
91 | | - System.out.println( |
92 | | - "Changes in version " + JsonPath.read(content, "$[0].milestone.title") + " (" + LocalDate.now() |
93 | | - + ")"); |
94 | | - System.out.println("----------------------------------------"); |
95 | | - } |
| 90 | + if (header) { |
| 91 | + System.out.println( |
| 92 | + "Changes in version " + JsonPath.read(content, "$[0].milestone.title") + " (" + LocalDate.now() |
| 93 | + + ")"); |
| 94 | + System.out.println("----------------------------------------"); |
| 95 | + } |
96 | 96 |
|
97 | | - for (Object title : titles) { |
| 97 | + for (Object title : titles) { |
98 | 98 |
|
99 | | - String format = String.format("- #%s - %s", ids.next(), title.toString().replaceAll("`", "")); |
100 | | - System.out.println(format.endsWith(".") ? format : format.concat(".")); |
101 | | - } |
102 | | - } |
| 99 | + String format = String.format("- #%s - %s", ids.next(), title.toString().replaceAll("`", "")); |
| 100 | + System.out.println(format.endsWith(".") ? format : format.concat(".")); |
| 101 | + } |
| 102 | + } |
103 | 103 | } |
0 commit comments