Skip to content

Conversation

@deepsm007
Copy link
Contributor

When a PR is created from an outdated base branch commit, git diff-tree comparisons can be incorrect because they compare against the old base SHA instead of finding the actual merge point.

This fix uses git merge-base to find the common ancestor between the base SHA and HEAD, ensuring accurate change detection even when:

  • The base branch has moved forward significantly
  • The PR was created from an outdated commit
  • Merge commits exist in the PR history

This resolves the issue where pj-rehearse fails to detect changes until the PR is rebased onto the latest base branch.

/cc @danilo-gemoli @openshift/test-platform

/hold

When a PR is created from an outdated base branch commit, git diff-tree
comparisons can be incorrect because they compare against the old base
SHA instead of finding the actual merge point.

This fix uses git merge-base to find the common ancestor between the
base SHA and HEAD, ensuring accurate change detection even when:
- The base branch has moved forward significantly
- The PR was created from an outdated commit
- Merge commits exist in the PR history

This resolves the issue where pj-rehearse fails to detect changes
until the PR is rebased onto the latest base branch.

Related: Fixes issue where rehearsable tests are not detected when
PR base branch is outdated
@openshift-ci-robot
Copy link
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci bot requested review from a team and danilo-gemoli December 15, 2025 14:10
@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

Walkthrough

This change modifies the getRevChanges function in pkg/config/release.go to calculate and use a merge-base as the reference point for diff computation. When merge-base succeeds, its trimmed result replaces the original base in the diff comparison; on failure, the function falls back to the original base. This refines change detection when the base branch has advanced.

Changes

Cohort / File(s) Summary
Merge-base calculation for diff refinement
pkg/config/release.go
Adds merge-base calculation to determine moving base for diffs in getRevChanges. Implements error-tolerant handling with fallback to original base; trims whitespace from merge-base result before using it as the left-hand side of diff-tree invocation. Preserves existing filtering, diff invocation, and post-processing logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify merge-base error handling and fallback semantics are correctly implemented
  • Confirm whitespace trimming logic handles edge cases properly
  • Assess impact on change detection accuracy when base branch has advanced
  • Ensure the diff-tree command structure is valid with the merge-base substitution
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between f0f4b3b and 017e948.

📒 Files selected for processing (1)
  • pkg/config/release.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • pkg/config/release.go
🔇 Additional comments (1)
pkg/config/release.go (1)

277-288: LGTM! Robust solution for accurate change detection.

The merge-base approach correctly handles the case where the base branch has advanced since the PR was created. The fallback logic (lines 281-284) ensures safe operation when merge-base fails (e.g., shallow clones, no common ancestor), preserving the original behavior. This makes the implementation more robust than the previous version.


Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepsm007

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 15, 2025
@deepsm007
Copy link
Contributor Author

/test images

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 15, 2025

@deepsm007: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/breaking-changes 017e948 link false /test breaking-changes
ci/prow/images 017e948 link true /test images

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@danilo-gemoli
Copy link
Contributor

I'm not sure the code we are changing here is ever exercised by pj-rehearse. If my understanding is correct, this is the relevant part. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants