This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch fix/changelog-range-dates
in repository https://gitbox.apache.org/repos/asf/maven-changelog-plugin.git

commit 86bcfb5862487eeedc3d26c418d3b14b0f2c879a
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Thu Dec 25 23:13:16 2025 +0000

    Fix changelog range type to use actual dates instead of null
    
    When type='range', the plugin was passing null for both startDate and
    endDate to the SCM provider, relying on the numDays parameter. This
    worked with 'git whatchanged' which had implicit date limiting, but
    fails with 'git log' which requires explicit --since/--until dates.
    
    Now the range (number of days) is converted to actual Date objects
    before being passed to the SCM provider, ensuring proper date
    filtering regardless of the underlying SCM command.
    
    Uses java.time API (Instant/ChronoUnit) instead of deprecated
    Calendar for date manipulation.
    
    Fixes: #200
---
 .../org/apache/maven/plugins/changelog/ChangeLogReport.java    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/src/main/java/org/apache/maven/plugins/changelog/ChangeLogReport.java 
b/src/main/java/org/apache/maven/plugins/changelog/ChangeLogReport.java
index 93221b4..0d880e0 100644
--- a/src/main/java/org/apache/maven/plugins/changelog/ChangeLogReport.java
+++ b/src/main/java/org/apache/maven/plugins/changelog/ChangeLogReport.java
@@ -32,6 +32,8 @@ import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
@@ -572,8 +574,14 @@ public class ChangeLogReport extends AbstractMavenReport {
             ChangeLogScmResult result;
 
             if ("range".equals(type)) {
+                // Calculate start and end dates based on the range (number of 
days)
+                Instant endInstant = Instant.now();
+                Instant startInstant = endInstant.minus(range, 
ChronoUnit.DAYS);
+                Date endDate = Date.from(endInstant);
+                Date startDate = Date.from(startInstant);
+
                 result = provider.changeLog(
-                        repository, new ScmFileSet(basedir), null, null, 
range, (ScmBranch) null, dateFormat);
+                        repository, new ScmFileSet(basedir), startDate, 
endDate, 0, (ScmBranch) null, dateFormat);
 
                 checkResult(result);
 

Reply via email to