Skip to content

Expose both author and committer from GitChangeSet - #3994

Open
apuig wants to merge 6 commits into
jenkinsci:masterfrom
apuig:authorAndCommiter
Open

apuig wants to merge 6 commits into
jenkinsci:masterfrom
apuig:authorAndCommiter

Conversation

@apuig

@apuig apuig commented Aug 8, 2026

Copy link
Copy Markdown

Fixes #3831
Related #2670 #2170 #3777

GitChangeSet parse both author and committer from every git commit, but both fields are private, the only way to read identity is through getAuthor() (plus getAuthorEmail()/getTimestamp/Date()), which return one identity selected by the authorOrCommitter flag. The ChangeLogSet.Entry interface only covers a single identity and a single timestamp, so git-plugin picked one and the other was unreachable. The flag default is intentional and unchanged to avoid behavior regressions.

Flag-independent identity getters

getGit{Author/Committer}{Name/Email/Date} six new @Exported methods on GitChangeSet.

These always return the raw Git field regardless of authorOrCommitter. No side effects from any extension.
getAuthor() is unchanged, only its Javadoc is updated to make the existing flag behavior explicit.

Changelog UI extension (opt-in, second commit)

Important

This second commit can be reverted or extracted to a follow-up PR without affecting the API getters.
It is included here as a concrete, working example of what the new API enables, e.g., making the rebase-merge commits immediately visible to developers browsing build changes.

A new ShowAuthorAndCommitterInChangelog extension, mirroring the existing authorOrCommitter pattern.

When enabled and author name differs from committer name, the changelog shows "authored by X · committed by Y". When identities match or the extension is absent, rendering is identical to today.

The extension does not affect getAuthor(). The two concerns are independent: AuthorInChangelog controls which identity Jenkins propagates as the SCM entry author to other plugin consumers; ShowAuthorAndCommitterInChangelog only controls whether the UI displays both.

Note

The flag is resolved at parse time. The result is stored in GitChangeSetList as a serialized field. Enabling or disabling the extension after a build has no effect on that build's changelog, only new builds pick up the change.

Compact mode (build summary widget, project Changes view) suppresses dual labels. Only the full Build / Changes page shows them.

Avatar: when both identities are shown the avatar still resolves from getAuthor(). Known gap, not practical to fix in Jelly without side effects.

Testing done

Tested locally with mvn hpi:run and a repo where some commits have author ≠ committer.

Extension enabled. Changes page:

screenshot-dual-identity

REST API:

curl -s "http://localhost:8080/jenkins/job/<JOB>/lastBuild/api/json?depth=2" \
  | jq '.changeSet.items[-1] | {msg, gitAuthorName, gitAuthorEmail, gitAuthorDate, gitCommitterName, gitCommitterEmail, gitCommitterDate}'
{
  "msg": "commit different identity",
  "gitAuthorName": "Alice Author",
  "gitAuthorEmail": "alice@example.com",
  "gitAuthorDate": "2026-08-01 09:15:00 +0200",
  "gitCommitterName": "GitHub Merge Bot",
  "gitCommitterEmail": "noreply@github.com",
  "gitCommitterDate": "2026-08-09 00:55:13 +0200"
}

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@apuig
apuig requested a review from a team as a code owner August 8, 2026 23:48
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests Automated test addition or improvement labels Aug 8, 2026
* When enabled, the changelog view displays both the Git author and committer
* with explicit labels, instead of showing only one identity.
*
* @since TODO

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we replace the @ since TODO with the actual plugin version this API is being introduced in? The Open Tasks Scanner is currently flagging this, and the same TODO appears on the other new public APIs in this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we can't, because we don't know the release that will include it.

Jenkins core uses a similar technique. @since TODO is added to indicate a new API. After the release of the new API, the value is updated in the Javadoc comment

Comment thread README.adoc

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The REST test requests depth 1 while traversing changeSet.items at two locations; update those requests to depth 2.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds flag-independent Git author/committer getters and opt-in changelog rendering for both identities.

Changes:

  • Exposes six exported author/committer name, email, and date getters.
  • Persists display configuration and renders dual identities in full changelog views.
  • Adds styling, documentation, localization, and test coverage.
File summaries
File Summary
src/test/java/hudson/plugins/git/GitChangeSetSimpleTest.java GitChangeSet behavior coverage.
src/test/java/hudson/plugins/git/GitChangeSetListTest.java Changelog list configuration and serialization coverage.
src/test/java/hudson/plugins/git/GitChangeSetIdentityTest.java Identity getters and REST export coverage.
src/test/java/hudson/plugins/git/GitChangeSetEuroTest.java Git identity and date parsing coverage.
src/test/java/hudson/plugins/git/GitChangeSetEmptyTest.java Empty-change-set regression coverage.
src/test/java/hudson/plugins/git/GitChangeSetBasicTest.java Basic GitChangeSet regression coverage.
src/test/java/hudson/plugins/git/extensions/impl/ShowAuthorAndCommitterInChangelogTest.java Extension configuration and rendering coverage.
src/main/resources/hudson/plugins/git/styles.css Styles dual-identity labels.
src/main/resources/hudson/plugins/git/GitChangeSetList/index.properties Adds localized identity labels.
src/main/resources/hudson/plugins/git/GitChangeSetList/index.jelly Renders both identities in full changelog views.
src/main/resources/hudson/plugins/git/extensions/impl/ShowAuthorAndCommitterInChangelog/help.html Documents the opt-in extension.
src/main/java/hudson/plugins/git/GitSCM.java Detects the display extension.
src/main/java/hudson/plugins/git/GitChangeSetList.java Stores the display setting.
src/main/java/hudson/plugins/git/GitChangeSet.java Adds author/committer getters.
src/main/java/hudson/plugins/git/GitChangeLogParser.java Propagates display configuration.
src/main/java/hudson/plugins/git/extensions/impl/ShowAuthorAndCommitterInChangelog.java Defines the opt-in extension.
README.adoc Documents configuration and APIs.
Review details

Suppressed comments (3)

src/main/java/hudson/plugins/git/GitChangeSet.java:309

  • The behavior here is controlled by the authorOrCommitter constructor flag, not by whether an AuthorInChangelog extension is present. GitChangeSet has public constructors that can set this flag directly, so describing the result only in terms of the extension makes this API documentation incorrect for direct callers; use the flag in these descriptions (and the analogous getAuthor* Javadocs).
    /**
     * Returns the committer date by default, or the author date when
     * {@link hudson.plugins.git.extensions.impl.AuthorInChangelog} is enabled.

src/main/java/hudson/plugins/git/GitChangeSet.java:338

  • This Javadoc describes getTimestamp() as returning a date, but the method returns a long epoch-millisecond timestamp. It also attributes the selection to an extension even though the public constructor flag controls it; document the selected timestamp and its units instead.
    /**
     * Returns the committer date by default, or the author date when
     * {@link hudson.plugins.git.extensions.impl.AuthorInChangelog} is enabled.
     *
     * @see #getDate()
     * @see #getGitAuthorDate()
     * @see #getGitCommitterDate()
     */

src/test/java/hudson/plugins/git/GitChangeSetIdentityTest.java:261

  • This request uses depth=1 but the assertions traverse two nested levels (changeSet.items). The depth-limited Jenkins export does not include the items array at this depth, so the test fails while reading the JSON; the REST example in the PR uses depth=2. Request depth 2 here as well.
        Page page = r.createWebClient().goTo(build.getUrl() + "api/json?depth=1", "application/json");
  • Files reviewed: 17/18 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/test/java/hudson/plugins/git/GitChangeSetIdentityTest.java
Comment thread README.adoc Outdated
Comment thread src/main/java/hudson/plugins/git/GitChangeLogParser.java
Comment thread src/main/java/hudson/plugins/git/GitChangeSet.java
Comment thread src/main/java/hudson/plugins/git/GitChangeSetList.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation tests Automated test addition or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-72820] GitChangeSet does not provide committer and author data at the same time

4 participants