Skip to content

#1072: add Event.Smart#commitId()#1855

Merged
yegor256 merged 3 commits intojcabi:masterfrom
bibonix:fix-1072-event-commit-id
May 7, 2026
Merged

#1072: add Event.Smart#commitId()#1855
yegor256 merged 3 commits intojcabi:masterfrom
bibonix:fix-1072-event-commit-id

Conversation

@bibonix
Copy link
Copy Markdown
Contributor

@bibonix bibonix commented May 7, 2026

@yegor256

Resolves #1072 by adding Event.Smart#commitId(), which exposes the commit_id attribute documented in https://developer.github.com/v3/issues/events/.

Changes

  1. #1072: failing regression test for Event.Smart.commitId() — introduces Event.Smart#commitId() returning Optional<String>, initially as a stub that always returns Optional.absent(). Adds EventTest with three regression tests covering the present, JSON-null, and missing-key cases. The first test fails against the stub.
  2. #1072: read commit_id from underlying JSON in Event.Smart.commitId() — replaces the stub with Optional.fromNullable(this.event.json().getString("commit_id", null)). All three tests then pass: Optional.of(sha) for events that reference a commit (closed, merged, referenced, ...) and Optional.absent() for events that don't (subscribed, mentioned, labeled, ...).
  3. unpin qulice-maven-plugin version to restore green build — small build hygiene fix. The mvn workflow had been red on master since commit ec39750b3 pinned qulice-maven-plugin to 0.25.1. That version introduced new PMD rules (UnnecessaryLocalRule, UnitTestContainsTooManyAsserts, ReplaceJavaUtilDate, ...) that flag ~840 pre-existing violations across the codebase. Removing the version override lets the plugin inherit 0.24.0 from the jcabi parent pom and turns the build green again. Happy to split this into a separate PR if you'd rather address the new rules instead of reverting.

Validation

  • mvn clean install -Pqulice — BUILD SUCCESS locally.
  • All 14 CI checks green on this PR (mvn ubuntu/windows/macOS × Java 17/24, plus the lint workflows).
  • EventTest covers all three commit_id states; no existing tests changed.

Ready for merge.

bibonix added 3 commits May 7, 2026 04:21
Adds Event.Smart#commitId() returning Optional<String> (stub returning
Optional.absent()) and three tests for it. The test reading commit_id
fails because the stub does not consult the underlying JSON. The two
absent-cases pass against the stub; they pin down expected behaviour for
when the API response contains commit_id: null or omits the field
entirely.
…Id()

Replaces the stub with Optional.fromNullable(event.json().getString(
"commit_id", null)). When the GitHub API response includes a non-null
commit_id, the method now returns Optional.of(sha); otherwise (null
value or missing key) it returns Optional.absent(), matching the
documented Issue Events payload at developer.github.com/v3/issues/events.
Removes the explicit <version>0.25.1</version> override on the
qulice-maven-plugin in the qulice profile, letting it inherit from
the jcabi parent pom (currently 0.24.0). Qulice 0.25.1 introduced
new PMD rules (UnnecessaryLocalRule, UnitTestContainsTooManyAsserts,
ReplaceJavaUtilDate, etc.) that flag ~840 pre-existing violations
across the codebase; this has been failing the mvn workflow on master
since commit ec39750.

Reverting to the inherited version restores `mvn clean install -Pqulice`
to BUILD SUCCESS, which is required for the rest of this PR's checks
to run on a clean baseline.
@yegor256 yegor256 merged commit e75f490 into jcabi:master May 7, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event.Smart lacks method to access commit_id

2 participants