feat: report the pull request's commit when CI checks out a merge commit - #9
Conversation
On pull request builds GitHub Actions checks out refs/pull/N/merge, so commitInfo returned "Merge <sha> into <sha>" with the merge commit's author. GitLab merged results pipelines, Azure Pipelines, Travis, Semaphore, Bitbucket Pipelines and Buildkite with the merge refspec do the same. The pull request's sha comes from the GitHub event file or the provider's environment variable. When that commit is a parent of the checked-out commit, its sha, message, author, email and timestamp are returned instead. In a depth-1 clone, the actions/checkout default, that one commit is fetched from origin with a 3s timeout. A failed fetch keeps the checked-out commit. CURRENTS_DISABLE_HEAD_COMMIT_FETCH=true skips the fetch. COMMIT_INFO_* variables still take priority, and COMMIT_INFO_SHA skips the lookup. engines.node goes to >=8 for async/await. Refs ENG-934 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdJrRhBLEH9Uwt97JMGVTR
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
Files not reviewed due to moderation or processing errors (4)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughThe change adds pull request head commit lookup to ChangesPull request head metadata
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant commitInfo
participant getPullRequestHeadCommit
participant Git
commitInfo->>getPullRequestHeadCommit: checkout SHA and GitHub event data
getPullRequestHeadCommit->>Git: check parents and commit availability
getPullRequestHeadCommit->>Git: fetch missing SHA when allowed
getPullRequestHeadCommit->>Git: read head commit metadata
getPullRequestHeadCommit-->>commitInfo: head commit data or null
Merge Risk: ⚪ Minimal · up to Pull-request builds now report the pull request's last commit instead of the CI merge commit. The reported data has the same shape as for other builds. When the head commit cannot be found or fetched, reporting falls back to the checked-out commit without errors. The minimum Node.js version rises to 8, as documented. No merge-blocking issues were found. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 3 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
A pull_request workflow runs commitInfo on the checkout actions/checkout makes: depth 1, full clone, git 2.25 in the Ubuntu 20.04 Playwright image, and with CURRENTS_DISABLE_HEAD_COMMIT_FETCH. Unit tests cover the 3s timeout against an origin that never answers, and three processes fetching the same commit at once. Version 1.1.0-beta.0 for the beta release. Refs ENG-934 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdJrRhBLEH9Uwt97JMGVTR
Refs ENG-934 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdJrRhBLEH9Uwt97JMGVTR
|
@baz review |
|
| Topic | Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| PR commit reporting | Report the pull request head commit from GitHub Actions and supported CI provider metadata, safely reading or fetching it from shallow clones while preserving existing overrides and failure behavior.Modified files (6)
Latest Contributors(2)
| |||||||||
| CI validation | Validate merge-checkout behavior across clone depths, Git versions, fetch failures, disabled fetching, and concurrent fetches using automated tests and a GitHub Actions workflow.Modified files (3)
Latest Contributors(1)
|
…commit A one-parent commit that a build adds on top of the pull request is a real commit and is reported as is. The PR workflow gets contents: read, since it runs the pull request's code. Refs ENG-934 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdJrRhBLEH9Uwt97JMGVTR
On pull request builds,
commitInfonow returns the pull request's last commit (sha, message, author, email, timestamp) instead of the merge commit the CI provider checks out. A GitHub Actionspull_requestrun with the defaultactions/checkoutreports the real commit instead of "Merge into ".@currents/cmdand@currents/playwrightget this with a version bump.How it works
pull_request.head.shain the GitHub event file (ghaEventData, which this package already reads), or from a provider variable:CI_MERGE_REQUEST_SOURCE_BRANCH_SHA(GitLab merged results),SYSTEM_PULLREQUEST_SOURCECOMMITID(Azure),TRAVIS_PULL_REQUEST_SHA,SEMAPHORE_GIT_PR_SHA,BUILDKITE_PULL_REQUEST_HEAD_COMMIT,BITBUCKET_COMMIT.git cat-file commit, which works in depth-1 clones whereHEAD^2does not. This skipspull_request_target, merge queue builds, and one-parent commits a build adds on top of the pull request.git fetch --depth=1 --no-tags origin <sha>, 3s timeout, no credential prompt, one retry when another process holds.git/shallow.lock. A full clone is never fetched into, because--depthwould make it shallow.CURRENTS_DISABLE_HEAD_COMMIT_FETCH=trueskips the fetch.COMMIT_INFO_*variables still take priority, andCOMMIT_INFO_SHAskips the lookup.git show -s --pretty=%Bgives today, including the trailing newline.engines.nodegoes from>=6to>=8for async/await. Version 1.1.0-beta.0, to publish under thebetatag first.No flag that needs a recent git:
--no-write-fetch-headneeds git 2.29, and the Ubuntu 20.04 images some users run ship git 2.25.Not covered
persistCredentialsdefaults to false, so the fetch fails and the merge commit is reported.Verification
Pull request commitworkflow runscommitInfoon this PR's own checkout fromactions/checkout@v4and compares it withgit showof the PR head. All four jobs pass:fetch-depth: 0): reported the PR head without fetchingmcr.microsoft.com/playwright:v1.28.1-focal: reported the PR head. The container needssafe.directory, as it already does for HEAD.CURRENTS_DISABLE_HEAD_COMMIT_FETCH=true: reported the merge commit, as beforecijob.standardpasses.refs/pull/1/merge. Cases:pull_request_targetcheckout, one-parent commit on top of the pull request, opt-out, failed fetch, outside a repo.git/shallow.lockon the first attempt and still return the commitcommitInfowith a GitHub event file,COMMIT_INFO_*prioritynpm pack --dry-runincludessrc/pull-request-head.jsand excludes the spec.Publishing needs #10 (publish workflow) on
master.Refs ENG-934
🤖 Generated with Claude Code
https://claude.ai/code/session_01LdJrRhBLEH9Uwt97JMGVTR