Skip to content

🐛 Use latest GitLab commit date for merge requests - #5339

Open
XY-code1 wants to merge 3 commits into
ossf:mainfrom
XY-code1:fix/gitlab-commit-date-boundary
Open

XY-code1 wants to merge 3 commits into
ossf:mainfrom
XY-code1:fix/gitlab-commit-date-boundary

Conversation

@XY-code1

@XY-code1 XY-code1 commented Oct 17, 2026 •

Copy link
Copy Markdown

What kind of change does this PR introduce?Bug fix.- [x] PR title follows the guidelines defined in our pull request documentation#### What is the current behavior?The GitLab client uses the first commit returned by the REST API as the mergedBefore bound for the merge-request GraphQL query. The API response is not guaranteed to be ordered, so an older first entry can exclude merge requests associated with newer commits and lower Code-Review results.#### What is the new behavior?The client finds the latest non-nil committed date in the returned commit set and uses it as the GraphQL bound. It does not reorder the commits, so the existing result order and zip behavior remain unchanged. Missing commit dates are ignored, with the existing nil-bound behavior retained when no date is available.- [x] Tests for the changes have been added (for bug fixes/features)The regression test covers an unordered response, missing dates, and an all-missing-date response.#### Which issue(s) this PR fixesFixes #3193#### Special notes for your reviewerThe earlier #4969 sorted the commit slice and was closed by its author after an unrelated verifier infrastructure failure. This version computes only the query bound, avoiding an observable commit-order change.Local validation:- gofmt completed for both changed files.- git diff --check passed before commit.- go test ./clients/gitlabrepo -run '^TestLatestCommittedDate$' -count=1 could not complete locally because this Windows host repeatedly failed IPv6 downloads from proxy.golang.org/goproxy.cn while fetching existing transitive modules. No dependency or lock-file changes were made. Hosted CI must execute the Go tests.#### Does this PR introduce a user-facing change?release-noteFix GitLab Code-Review analysis to use the newest returned commit date when selecting merge requests.

@XY-code1
XY-code1 requested a review from a team as a code owner October 17, 2026 06:41
@XY-code1
XY-code1 requested review from justaugustus and spencerschrock and removed request for a team October 17, 2026 06:41
@XY-code1

Copy link
Copy Markdown
Author

@justaugustus @spencerschrock Could you please review this PR when convenient?

I have synchronized the branch with the latest main (0fa61d19ca) using a normal merge and rechecked the implementation against #3193. The change remains intentionally narrow:

  • computes the newest non-nil CommittedDate across the unordered GitLab REST response;
  • uses that date only as the GraphQL mergedBefore bound;
  • preserves the original commit slice order and existing zip behavior;
  • retains a nil bound when no commit date is available;
  • adds table-driven coverage for unordered, partially missing, and entirely missing dates.

Validation after synchronization:

  • gofmt produced no semantic changes
  • git diff --check passed
  • the focused Go test is still blocked locally by repeated dependency-download timeouts to proxy.golang.org; no dependency files were changed

A fresh hosted CI run has been requested and is awaiting maintainer workflow approval. Thank you!

@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.33%. Comparing base (353ed60) to head (09fad54).
⚠️ Report is 423 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5339       +/-   ##
===========================================
+ Coverage   66.80%   77.33%   +10.52%     
===========================================
  Files         230      255       +25     
  Lines       16602    14470     -2132     
===========================================
+ Hits        11091    11190       +99     
+ Misses       4808     3279     -1529     
+ Partials      703        1      -702     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 result-building path can still panic when returned commits have missing dates; this handling must be fixed before approval.

1 open issue
What changed in this PR

This pull request updates GitLab merge-request lookup to use the latest non-nil commit date as the mergedBefore query bound without changing commit order.

Changes:

  • Computes the newest available committed date from unordered API results.
  • Preserves existing commit ordering and nil-bound behavior.
  • Adds regression coverage for unordered commits and missing dates.
File Description
clients/​gitlabrepo/​client.go Uses the latest committed date for GraphQL merge-request queries.
clients/​gitlabrepo/​client_test.go Tests latest-date selection and missing-date handling.

Review effort: Lite

Comment thread clients/gitlabrepo/client.go Resolved
Signed-off-by: XY-code1 <1611761391@qq.com>
Signed-off-by: XY-code1 <1611761391@qq.com>
@XY-code1
XY-code1 force-pushed the fix/gitlab-commit-date-boundary branch from 3ba8e1f to 09fad54 Compare October 24, 2026 06:16
@XY-code1
XY-code1 deployed to integration-test October 24, 2026 07:18 — with GitHub Actions Active
Signed-off-by: XY-code1 <1611761391@qq.com>
@XY-code1

Copy link
Copy Markdown
Author

@justaugustus @spencerschrock The reported nil-date panic and lint failure are now fixed.

Changes:

  • use the latest non-nil GitLab commit date for the MR query boundary;
  • tolerate commits with missing dates in the result-building path;
  • add a full ListCommits regression test;
  • rebase onto current main;
  • fix fieldalignment and DCO issues.

Local validation passed:

  • targeted GitLab client tests
  • go vet ./clients/gitlabrepo/...
  • gofmt
  • git diff --check

Could one of you please approve the pending workflows and review the PR when convenient? Thanks!

This branch was successfully deployed

2 active (outdated) deployments
gitlab — 09fad542 Deployed Oct 24, 2026 by XY-code1 via gitlab-integration-trusted #5521
integration-test — 09fad542 Deployed Oct 24, 2026 by XY-code1 via integration-trusted #12843
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants