Skip to content

Commit

Permalink
fix: avoid modifying state of context in eachUrlPart
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Jan 26, 2025
1 parent 57a9407 commit b218055
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies {

testImplementation 'org.slf4j:slf4j-simple:2.0.16'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.assertj:assertj-core:3.27.2'
testImplementation 'org.assertj:assertj-core:3.27.3'
testImplementation 'com.approvaltests:approvaltests:24.14.2'
testImplementation 'org.mockito:mockito-core:5.15.2'
}
6 changes: 4 additions & 2 deletions src/main/java/se/bjurr/gitchangelog/api/helpers/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.github.jknack.handlebars.Options.Buffer;
import com.github.jknack.handlebars.helper.EachHelper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -243,8 +244,9 @@ public static Map<String, Helper<?>> getAll() {
helpers.put(
"eachUrlPart",
(final Changelog changelog, final Options options) -> {
Collections.reverse(changelog.getUrlParts());
return each(options, changelog.getUrlParts());
List<String> reversedList = new ArrayList<>(changelog.getUrlParts());
Collections.reverse(reversedList);
return each(options, reversedList);
});
return helpers;
}
Expand Down

0 comments on commit b218055

Please # to comment.