Skip to content

Commit 8ff6ba1

Browse files
committed
Cleanup and comments
1 parent 27a612f commit 8ff6ba1

File tree

3 files changed

+16
-33
lines changed

3 files changed

+16
-33
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/BundleChangelogsTask.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ public BundleChangelogsTask(ObjectFactory objectFactory, ExecOperations execOper
103103
gitWrapper = new GitWrapper(execOperations);
104104
}
105105

106+
/*
107+
Given a branch, and possibly a build candidate commit sha
108+
Check out the changelog yaml files from the branch/BC sha
109+
Then, bundle them all up into one file and write it to disk, along with a timestamp and whether the release is considered released
110+
111+
When using a branch without a BC sha:
112+
- Check out the changelog yaml files from the HEAD of the branch
113+
114+
When using a BC sha:
115+
- Check out the changelog yaml files from the BC commit
116+
- Update those files with any updates from the HEAD of the branch (in case the changelogs get modified later)
117+
- Check for any changelog yaml files that were added AFTER the BC,
118+
but whose PR was merged before the BC (in case someone adds a forgotten changelog after the fact)
119+
*/
106120
@TaskAction
107121
public void executeTask() throws IOException {
108122
if (branch == null) {
@@ -145,7 +159,7 @@ public void executeTask() throws IOException {
145159
return true;
146160
}
147161

148-
// If the changelog was present in the BC sha, use it
162+
// If the changelog was present in the BC sha, always use it
149163
if (finalEntriesFromBc.contains(f.getName())) {
150164
return true;
151165
}

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/GenerateReleaseNotesTask.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import org.elasticsearch.gradle.VersionProperties;
1515
import org.gradle.api.DefaultTask;
16-
import org.gradle.api.GradleException;
1716
import org.gradle.api.file.Directory;
1817
import org.gradle.api.file.DirectoryProperty;
1918
import org.gradle.api.file.RegularFile;
@@ -32,7 +31,6 @@
3231
import java.util.Comparator;
3332
import java.util.HashSet;
3433
import java.util.List;
35-
import java.util.Map;
3634

3735
import javax.inject.Inject;
3836

@@ -82,7 +80,6 @@ public void executeTask() throws IOException {
8280
}
8381

8482
LOGGER.info("Finding changelog bundles...");
85-
8683
List<ChangelogBundle> allBundles = this.changelogBundleDirectory.getAsFileTree()
8784
.getFiles()
8885
.stream()
@@ -126,18 +123,7 @@ static List<ChangelogBundle> getSortedBundlesWithUniqueChangelogs(List<Changelog
126123
*/
127124
private static void findAndUpdateUpstreamRemote(GitWrapper gitWrapper) {
128125
LOGGER.info("Finding upstream git remote");
129-
// We need to ensure the tags are up-to-date. Find the correct remote to use
130-
String upstream = gitWrapper.listRemotes()
131-
.entrySet()
132-
.stream()
133-
.filter(entry -> entry.getValue().contains("elastic/elasticsearch"))
134-
.findFirst()
135-
.map(Map.Entry::getKey)
136-
.orElseThrow(
137-
() -> new GradleException(
138-
"I need to ensure the git tags are up-to-date, but I couldn't find a git remote for [elastic/elasticsearch]"
139-
)
140-
);
126+
String upstream = gitWrapper.getUpstream();
141127

142128
LOGGER.info("Updating remote [{}]", upstream);
143129
// Now update the remote, and make sure we update the tags too

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/ReleaseNotesGenerator.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,8 @@ static String generateFile(String template, List<ChangelogBundle> bundles) throw
109109
bundlesWrapped.add(wrapped);
110110
}
111111

112-
// final var changelogsByTypeByArea = buildChangelogBreakdown(changelogs);
113-
//
114-
// final Map<Boolean, List<ChangelogEntry.Highlight>> groupedHighlights = changelogs.stream()
115-
// .map(ChangelogEntry::getHighlight)
116-
// .filter(Objects::nonNull)
117-
// .sorted(comparingInt(ChangelogEntry.Highlight::getPr))
118-
// .collect(groupingBy(ChangelogEntry.Highlight::isNotable, toList()));
119-
//
120-
// final List<ChangelogEntry.Highlight> notableHighlights = groupedHighlights.getOrDefault(true, List.of());
121-
// final List<ChangelogEntry.Highlight> nonNotableHighlights = groupedHighlights.getOrDefault(false, List.of());
122-
123112
final Map<String, Object> bindings = new HashMap<>();
124-
// bindings.put("version", version);
125-
// bindings.put("changelogsByTypeByArea", changelogsByTypeByArea);
126113
bindings.put("TYPE_LABELS", TYPE_LABELS);
127-
// bindings.put("unqualifiedVersion", version.withoutQualifier());
128-
// bindings.put("versionWithoutSeparator", version.withoutQualifier().toString().replaceAll("\\.", ""));
129-
// bindings.put("notableHighlights", notableHighlights);
130-
// bindings.put("nonNotableHighlights", nonNotableHighlights);
131114
bindings.put("changelogBundles", bundlesWrapped);
132115

133116
return TemplateUtils.render(template, bindings);

0 commit comments

Comments
 (0)