GabriRuflex opened a new pull request, #1381:
URL: https://github.com/apache/maven-scm/pull/1381

   ## What does this PR do?
   
   The Git `info` command always passed `--no-merges` to `git log`, so the 
reported revision could differ
   from the actual `HEAD` in merge-based release workflows. This surfaced 
downstream as a regression in
   
[buildnumber-maven-plugin#229](https://github.com/mojohaus/buildnumber-maven-plugin/issues/229)
 (which
   switched from `git rev-parse --verify HEAD` to `git log -1 --no-merges`).
   
   As requested in #1327, this makes the behavior configurable via a new
   `CommandParameter.SCM_SKIP_MERGE_COMMITS` parameter (`"skipMergeCommits"`):
   
   - Default `true` — skip merge commits (**current behavior, fully backward 
compatible**).
   - Set to `false` to include merge commits, so the reported revision matches 
the actual `HEAD`.
   
   ## Changes
   
   - **`maven-scm-api`** — new public `CommandParameter.SCM_SKIP_MERGE_COMMITS` 
(`@since 2.2.2`).
   - **`maven-scm-provider-gitexe`** — `GitInfoCommand` adds `--no-merges` only 
when the flag is `true`
     (null-safe reader mirroring the existing `shortRevisionLength` handling, 
plus a
     `DEFAULT_SKIP_MERGE_COMMITS` constant).
   - **`maven-scm-provider-jgit`** — `JGitInfoCommand` now honors the same flag 
by applying
     `RevFilter.NO_MERGES` for both the `HEAD` and the per-file lookups. 
Previously the JGit provider
     **never** filtered merge commits, diverging from gitexe; it is now 
consistent with it (with the
     default `true`, JGit skips merge commits as gitexe already did).
   
   ## Tests
   
   - `GitInfoCommandTest` (gitexe): asserts `--no-merges` is present by default 
and absent when
     `skipMergeCommits=false`.
   - New `JGitInfoCommandTest`: builds a repository whose `HEAD` is a 
no-fast-forward merge commit and
     verifies that the merge commit is reported when `skipMergeCommits=false` 
and skipped by default.
   - The existing Info command TCK tests (which pass `null` parameters) keep 
passing, confirming the
     default behavior is unchanged for both providers.
   
   ## Notes
   
   This is the enabling change on the maven-scm side. To fully address 
buildnumber-maven-plugin#229, the
   plugin will need to expose an option that sets `SCM_SKIP_MERGE_COMMITS = 
false` on the
   `CommandParameters` it passes to `ScmProvider#info`.
   
   Fixes #1327
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to