Skip to content

Add --conflict-policy flag to detect upstream dropped content#78

Open
mpryc wants to merge 1 commit intoopenshift-eng:mainfrom
mpryc:issue_77
Open

Add --conflict-policy flag to detect upstream dropped content#78
mpryc wants to merge 1 commit intoopenshift-eng:mainfrom
mpryc:issue_77

Conversation

@mpryc
Copy link
Contributor

@mpryc mpryc commented Feb 18, 2026

Fixes #77

When cherry-picking downstream carry patches, -Xtheirs silently resolves content conflicts by favoring the downstream version, which can drop upstream additions without any warning.

Add a new --conflict-policy flag with three modes:

  • auto: no detection (default, preserves existing behavior)
  • warn: log warnings when upstream content may have been lost
  • strict: fail when upstream content is lost

The detection compares each cherry-picked file against the upstream version to find missing lines after -Xtheirs resolution.

@openshift-ci openshift-ci bot requested review from mdbooth and racheljpg February 18, 2026 11:11
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 18, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mpryc
Once this PR has been reviewed and has the lgtm label, please assign damdo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 18, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 18, 2026

Hi @mpryc. Thanks for your PR.

I'm waiting for a openshift-eng member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@mpryc
Copy link
Contributor Author

mpryc commented Feb 18, 2026

Now with the strict mode rebasebot works as expected:

$ rebasebot   --source "https://github.com/vmware-tanzu/velero-plugin-for-aws:main"   --dest "openshift/velero-plugin-for-aws:oadp-dev"   --rebase "oadp-rebasebot/velero-plugin-for-aws:rebase-bot-oadp-dev"   --git-username "oadp-team-rebase-bot"   --git-email "oadp-maintainers@redhat.com"   --github-app-id "1810299"   --github-app-key "/home/migi/.rebasebot/secrets/oadp-rebasebot-app-key"   --github-cloner-id "1810272"   --github-cloner-key "/home/migi/.rebasebot/secrets/oadp-rebasebot-cloner-key"   --conflict-policy strict --post-rebase-hook   git:https://github.com/oadp-rebasebot/oadp-rebase/oadp-dev:rebasebot-hook-scripts/go-replace_velero_oadp-dev.sh   git:https://github.com/oadp-rebasebot/oadp-rebase/oadp-dev:rebasebot-hook-scripts/go-mod-tidy-and-commit.sh    --always-run-hooks --dry-run
INFO - Logging to GitHub as an Application for repository https://github.com/openshift/velero-plugin-for-aws
INFO - Logging to GitHub as an Application for repository https://github.com/oadp-rebasebot/velero-plugin-for-aws
INFO - Destination repository is https://github.com/openshift/velero-plugin-for-aws.git
INFO - rebase repository is https://github.com/oadp-rebasebot/velero-plugin-for-aws.git
INFO - source repository is https://github.com/vmware-tanzu/velero-plugin-for-aws.git
INFO - Fetching oadp-dev from dest
INFO - Fetching main from source
INFO - Fetching all tags from source
INFO - Fetching all branches from source
INFO - Checking out source/main
INFO - Checking for existing rebase branch rebase-bot-oadp-dev in https://github.com/oadp-rebasebot/velero-plugin-for-aws
INFO - Fetching existing rebase branch
INFO - Branches with commit:
  rebase/rebase-bot-oadp-dev
  source/HEAD -> source/main
  source/main
INFO - Preparing rebase branch
INFO - Merging upstream/main into oadp-dev
INFO - Performing rebase
INFO - Merge base of source/main and dest/oadp-dev: e930be50d4fb45c2fadafee7189b692c7156992a
INFO - Merges on ancestry-path from merge_base=(e930be50d4fb45c2fadafee7189b692c7156992a) to dest/oadp-dev branch:
7174af15e9625e981400d061bf3feea1f24600e3 || Merge pull request #117 from oadp-rebasebot/rebase-bot-oadp-dev || 138787+weshayutin@users.noreply.github.com
eb1418862addee658eb15e4bf73d005218179a31 || merge upstream/main into oadp-dev || oadp-maintainers@redhat.com
INFO - Searching for merge commit from previous rebasebot run to identify downstream commits
INFO - Found merge commit from previous rebase: eb1418862addee658eb15e4bf73d005218179a31
INFO - Its parent e930be50d4fb45c2fadafee7189b692c7156992a is on an upstream branch
INFO - Cutoff commits: ['^db5a2803e74708b3756d2fe39e7318e0dbbc963d', '^e930be50d4fb45c2fadafee7189b692c7156992a']
INFO - Identified downstream commits:
1866f267d181927f001e815543f958aaab71869c || adding Dockerfile.ubi || sseago@redhat.com
057dd5fb9d084096d1002b263ee5688915e18715 || Wait for snapshot to be ready before restoring || sseago@redhat.com
414ecb301c2bfa6e2fa304d8351f8741da3c906e || Add BZ automation to repo || rayfordj@redhat.com
3dfa6400d5d4cef58f1c36e0a24a5be3080603b7 || swapping out the builder image to konveyor/builder || jdevmane@redhat.com
cf1beecdb95fa8e0fffb8e7859fb597fd0b82eec || Enable multiarch builds || jmontleo@redhat.com
897ccc970b05954ff1701197fe8a5f2488ea4d56 || Use arm64-graviton2 for arm builds || jmontleo@redhat.com
7390134812187fb2e50aa394e2ad44d39096512f || Add required keys for arm builds || jmontleo@redhat.com
73ce2fad58910749416de4fadf83a580573f58d1 || Use numeric non-root user for nonroot SCC compatibility || jmontleo@redhat.com
4844a31be3390a09e141939b5ee9eb508a2df024 || use full vm for arm builds in travis || sseago@redhat.com
5eec6785546e44fa15e39328e8835bf92634d5a0 || OADP-3586: Update to ubi9 builder and base images || weshayutin@gmail.com
ea13afe16232274877c0f48a6158b4ea228c37a6 || `snapshot.State == ""` typo || tkaovila@redhat.com
2c43efdf3cfd2260db2fce853f1978b1e6cf14d3 || fix: ARM images (#55) || msouzaol@redhat.com
e7f20ec6248bab29b048c14b633027147295f920 || ubi: BUILDPLATFORM to build stage to enable cross compile. (#57) || passawit.kaovilai@gmail.com
ab6d13c6f4a6b8414df3bda7c9d378cf3df4728c || add DOWNSTREAM_OWNERS || tkaovila@redhat.com
0b6b73b4079bcea82cfcb3369869804ff09a74ea || UPSTREAM: <drop>: Updating go modules || oadp-maintainers@redhat.com
INFO - Picking commit: 1866f267d181927f001e815543f958aaab71869c - adding Dockerfile.ubi
INFO - Picking commit: 057dd5fb9d084096d1002b263ee5688915e18715 - Wait for snapshot to be ready before restoring
WARNING - Upstream content may have been dropped from 'velero-plugin-for-aws/volume_snapshotter.go' by cherry-pick of: 057dd5fb9d084096d1002b263ee5688915e18715 - Wait for snapshot to be ready before restoring
WARNING -   lost line: ebsCSIDriver   = "ebs.csi.aws.com"
WARNING -   lost line: ebsKmsKeyIDKey = "ebsKmsKeyId"
WARNING -   lost line: ebsKmsKeyId string
WARNING -   lost line: ec2         *ec2.Client
WARNING -   lost line: if err := veleroplugin.ValidateVolumeSnapshotterConfigKeys(config, regionKey, credentialProfileKey, credentialsFileKey, enableSharedConfigKey, ebsKmsKeyIDKey); err != nil {
WARNING -   lost line: log         logrus.FieldLogger
WARNING -   lost line: regionKey      = "region"
ERROR - Manual intervention is needed to rebase https://github.com/vmware-tanzu/velero-plugin-for-aws:main into openshift/velero-plugin-for-aws:oadp-dev

$ echo $?

Current behavior was silently missing those, so it was going straight to the go mod update:

$ rebasebot   --source "https://github.com/vmware-tanzu/velero-plugin-for-aws:main"   --dest "openshift/velero-plugin-for-aws:oadp-dev"   --rebase "oadp-rebasebot/velero-plugin-for-aws:rebase-bot-oadp-dev"   --git-username "oadp-team-rebase-bot"   --git-email "oadp-maintainers@redhat.com"   --github-app-id "1810299"   --github-app-key "/home/migi/.rebasebot/secrets/oadp-rebasebot-app-key"   --github-cloner-id "1810272"   --github-cloner-key "/home/migi/.rebasebot/secrets/oadp-rebasebot-cloner-key" --post-rebase-hook   git:https://github.com/oadp-rebasebot/oadp-rebase/oadp-dev:rebasebot-hook-scripts/go-replace_velero_oadp-dev.sh   git:https://github.com/oadp-rebasebot/oadp-rebase/oadp-dev:rebasebot-hook-scripts/go-mod-tidy-and-commit.sh    --always-run-hooks --dry-run
INFO - Logging to GitHub as an Application for repository https://github.com/openshift/velero-plugin-for-aws
INFO - Logging to GitHub as an Application for repository https://github.com/oadp-rebasebot/velero-plugin-for-aws
INFO - Destination repository is https://github.com/openshift/velero-plugin-for-aws.git
INFO - rebase repository is https://github.com/oadp-rebasebot/velero-plugin-for-aws.git
INFO - source repository is https://github.com/vmware-tanzu/velero-plugin-for-aws.git
INFO - Fetching oadp-dev from dest
INFO - Fetching main from source
INFO - Fetching all tags from source
INFO - Fetching all branches from source
INFO - Checking out source/main
INFO - Checking for existing rebase branch rebase-bot-oadp-dev in https://github.com/oadp-rebasebot/velero-plugin-for-aws
INFO - Fetching existing rebase branch
INFO - Branches with commit:
  rebase/rebase-bot-oadp-dev
  source/HEAD -> source/main
  source/main
INFO - Preparing rebase branch
INFO - Merging upstream/main into oadp-dev
INFO - Performing rebase
INFO - Merge base of source/main and dest/oadp-dev: e930be50d4fb45c2fadafee7189b692c7156992a
INFO - Merges on ancestry-path from merge_base=(e930be50d4fb45c2fadafee7189b692c7156992a) to dest/oadp-dev branch:
7174af15e9625e981400d061bf3feea1f24600e3 || Merge pull request #117 from oadp-rebasebot/rebase-bot-oadp-dev || 138787+weshayutin@users.noreply.github.com
eb1418862addee658eb15e4bf73d005218179a31 || merge upstream/main into oadp-dev || oadp-maintainers@redhat.com
INFO - Searching for merge commit from previous rebasebot run to identify downstream commits
INFO - Found merge commit from previous rebase: eb1418862addee658eb15e4bf73d005218179a31
INFO - Its parent e930be50d4fb45c2fadafee7189b692c7156992a is on an upstream branch
INFO - Cutoff commits: ['^db5a2803e74708b3756d2fe39e7318e0dbbc963d', '^e930be50d4fb45c2fadafee7189b692c7156992a']
INFO - Identified downstream commits:
1866f267d181927f001e815543f958aaab71869c || adding Dockerfile.ubi || sseago@redhat.com
057dd5fb9d084096d1002b263ee5688915e18715 || Wait for snapshot to be ready before restoring || sseago@redhat.com
414ecb301c2bfa6e2fa304d8351f8741da3c906e || Add BZ automation to repo || rayfordj@redhat.com
3dfa6400d5d4cef58f1c36e0a24a5be3080603b7 || swapping out the builder image to konveyor/builder || jdevmane@redhat.com
cf1beecdb95fa8e0fffb8e7859fb597fd0b82eec || Enable multiarch builds || jmontleo@redhat.com
897ccc970b05954ff1701197fe8a5f2488ea4d56 || Use arm64-graviton2 for arm builds || jmontleo@redhat.com
7390134812187fb2e50aa394e2ad44d39096512f || Add required keys for arm builds || jmontleo@redhat.com
73ce2fad58910749416de4fadf83a580573f58d1 || Use numeric non-root user for nonroot SCC compatibility || jmontleo@redhat.com
4844a31be3390a09e141939b5ee9eb508a2df024 || use full vm for arm builds in travis || sseago@redhat.com
5eec6785546e44fa15e39328e8835bf92634d5a0 || OADP-3586: Update to ubi9 builder and base images || weshayutin@gmail.com
ea13afe16232274877c0f48a6158b4ea228c37a6 || `snapshot.State == ""` typo || tkaovila@redhat.com
2c43efdf3cfd2260db2fce853f1978b1e6cf14d3 || fix: ARM images (#55) || msouzaol@redhat.com
e7f20ec6248bab29b048c14b633027147295f920 || ubi: BUILDPLATFORM to build stage to enable cross compile. (#57) || passawit.kaovilai@gmail.com
ab6d13c6f4a6b8414df3bda7c9d378cf3df4728c || add DOWNSTREAM_OWNERS || tkaovila@redhat.com
0b6b73b4079bcea82cfcb3369869804ff09a74ea || UPSTREAM: <drop>: Updating go modules || oadp-maintainers@redhat.com
INFO - Picking commit: 1866f267d181927f001e815543f958aaab71869c - adding Dockerfile.ubi
INFO - Picking commit: 057dd5fb9d084096d1002b263ee5688915e18715 - Wait for snapshot to be ready before restoring
INFO - Picking commit: 414ecb301c2bfa6e2fa304d8351f8741da3c906e - Add BZ automation to repo
INFO - Picking commit: 3dfa6400d5d4cef58f1c36e0a24a5be3080603b7 - swapping out the builder image to konveyor/builder
INFO - Picking commit: cf1beecdb95fa8e0fffb8e7859fb597fd0b82eec - Enable multiarch builds
INFO - Picking commit: 897ccc970b05954ff1701197fe8a5f2488ea4d56 - Use arm64-graviton2 for arm builds
INFO - Picking commit: 7390134812187fb2e50aa394e2ad44d39096512f - Add required keys for arm builds
INFO - Picking commit: 73ce2fad58910749416de4fadf83a580573f58d1 - Use numeric non-root user for nonroot SCC compatibility
INFO - Picking commit: 4844a31be3390a09e141939b5ee9eb508a2df024 - use full vm for arm builds in travis
INFO - Picking commit: 5eec6785546e44fa15e39328e8835bf92634d5a0 - OADP-3586: Update to ubi9 builder and base images
INFO - Picking commit: ea13afe16232274877c0f48a6158b4ea228c37a6 - `snapshot.State == ""` typo
INFO - Picking commit: 2c43efdf3cfd2260db2fce853f1978b1e6cf14d3 - fix: ARM images (#55)
INFO - Picking commit: e7f20ec6248bab29b048c14b633027147295f920 - ubi: BUILDPLATFORM to build stage to enable cross compile. (#57)
INFO - Picking commit: ab6d13c6f4a6b8414df3bda7c9d378cf3df4728c - add DOWNSTREAM_OWNERS
INFO - Picking commit: 0b6b73b4079bcea82cfcb3369869804ff09a74ea - UPSTREAM: <drop>: Updating go modules
INFO - Running LifecycleHook.POST_REBASE lifecycle hook git:https://github.com/oadp-rebasebot/oadp-rebase/oadp-dev:rebasebot-hook-scripts/go-replace_velero_oadp-dev.sh
INFO - Running LifecycleHook.POST_REBASE lifecycle hook git:https://github.com/oadp-rebasebot/oadp-rebase/oadp-dev:rebasebot-hook-scripts/go-mod-tidy-and-commit.sh
Performing go modules update

  When cherry-picking downstream carry patches, -Xtheirs silently resolves
  content conflicts by favoring the downstream version, which can drop
  upstream additions without any warning.

  Add a new --conflict-policy flag with three modes:
  - auto: no detection (default, preserves existing behavior)
  - warn: log warnings when upstream content may have been lost
  - strict: fail when upstream content is lost

  The detection compares each cherry-picked file against the upstream
  version to find missing lines after -Xtheirs resolution.

Fixes openshift-eng#77

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Michal Pryc <mpryc@redhat.com>
@weshayutin
Copy link

0/ little help?

@mpryc
Copy link
Contributor Author

mpryc commented Mar 6, 2026

May I ask for review? It is required by the oadp projects. Without this OADP is missing important patches that were in downstream repos. @RadekManak ?

@damdo
Copy link
Contributor

damdo commented Mar 6, 2026

@RadekManak is out this week, he might be able to review when he's back next week

@RadekManak
Copy link
Contributor

/ok-to-test
@coderabbitai full review

@openshift-ci openshift-ci bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 11, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

Walkthrough

This PR introduces a conflict-aware cherry-pick workflow that detects conflicting files before applying -Xtheirs, checks for upstream content loss afterward, and provides configurable policies (auto/warn/strict) to handle detected losses. A new CLI argument propagates the policy through bot logic, with comprehensive tests validating behavior across scenarios.

Changes

Cohort / File(s) Summary
Conflict Detection & Handling
rebasebot/bot.py
Added three new helper functions: _detect_conflicting_files() to identify conflicting files without -Xtheirs, _check_upstream_content_loss() to compare upstream vs. current content and report lost lines per file, and _safe_cherry_pick() to execute cherry-pick with -Xtheirs and verify content loss for conflicted files. Updated _do_rebase(), _cherrypick_art_pull_request(), and run() signatures to accept conflict_policy parameter and replaced direct cherry-pick calls with _safe_cherry_pick() throughout rebase and PR handling flows. Control flow now probes for conflicts before cherry-pick when policy is not "auto", logs warnings/errors based on policy, and raises exceptions for strict policy violations.
CLI Integration
rebasebot/cli.py
Added new --conflict-policy argument with choices auto, warn, strict (default: auto). Updated rebasebot_run() to extract and pass the conflict policy value to bot.run() call.
Test Coverage
tests/test_conflict_policy.py
Introduced comprehensive new test module with four test cases validating conflict-policy behavior: test_auto_policy_silent_on_conflict(), test_warn_policy_logs_warning_on_content_loss(), test_strict_policy_fails_on_content_loss(), and test_strict_policy_succeeds_when_no_conflict(). Tests use predefined code snippets to simulate upstream/downstream divergence and verify outcomes via mocking and assertion.
Existing Test Updates
tests/test_rebases.py
Updated all test cases to set args.conflict_policy = "auto" to ensure compatibility with the new conflict-policy parameter threading through dry-run and rebase flows.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI/User
    participant Bot as Bot.run()
    participant Rebase as _do_rebase()
    participant SafePick as _safe_cherry_pick()
    participant Detect as _detect_conflicting_files()
    participant Check as _check_upstream_content_loss()
    participant Git as Git Operations

    CLI->>Bot: run(conflict_policy=policy)
    Bot->>Rebase: _do_rebase(conflict_policy=policy)
    loop For each commit to cherry-pick
        alt policy != "auto"
            Rebase->>Detect: Probe for conflicts without -Xtheirs
            Detect->>Git: Attempt cherry-pick
            Detect-->>Rebase: Return conflicting files
        end
        Rebase->>SafePick: _safe_cherry_pick(sha, conflict_policy)
        SafePick->>Git: Execute cherry-pick with -Xtheirs
        alt Conflicting files exist
            SafePick->>Check: Check for upstream content loss
            Check->>Git: Compare upstream vs. current content
            Check-->>SafePick: Report lost lines per file
            alt policy == "strict"
                SafePick-->>Rebase: Raise RepoException
            else policy == "warn"
                SafePick-->>Rebase: Log warning
            else policy == "auto"
                SafePick-->>Rebase: Silent (no-op)
            end
        end
        SafePick-->>Rebase: Pick complete
    end
    Rebase-->>Bot: Rebase finished
    Bot-->>CLI: Return result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Assessment against linked issues

Objective Addressed Explanation
Detect conflicts before applying -Xtheirs [#77]
Report when conflicts cause upstream content loss [#77]
Provide configurable policy for handling detected loss (auto/warn/strict) [#77]
Prevent silent drops of upstream additions without intervention [#77]
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

@RadekManak Sure! I'll perform a full review of PR #78 now.

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rebasebot/bot.py (1)

542-570: ⚠️ Potential issue | 🟠 Major

Use the upstream branch, not dest.branch, for ART conflict checks.

_safe_cherry_pick() interprets source_branch as the branch under the source/ remote. Passing dest.branch here means ART PR checks look up source/<dest.branch>. When source and dest branch names differ, every lookup falls into the GitCommandError path and detection is effectively disabled for ART commits.

Possible fix
-def _cherrypick_art_pull_request(gitwd: git.Repo, dest_repo: Repository, dest: GitHubBranch,
-                                 conflict_policy: str = "auto") -> None:
+def _cherrypick_art_pull_request(
+    gitwd: git.Repo,
+    dest_repo: Repository,
+    dest: GitHubBranch,
+    source_branch: str,
+    conflict_policy: str = "auto",
+) -> None:
@@
                 _safe_cherry_pick(
                     gitwd=gitwd,
                     sha=commit.sha,
-                    source_branch=dest.branch,
+                    source_branch=source_branch,
                     conflict_policy=conflict_policy,
                     commit_description=f"ART PR commit {commit.sha}"
                 )
-            _cherrypick_art_pull_request(gitwd, dest_repo, dest, conflict_policy)
+            _cherrypick_art_pull_request(
+                gitwd, dest_repo, dest, source.branch, conflict_policy
+            )

Also applies to: 963-963

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rebasebot/bot.py` around lines 542 - 570, The ART cherry-pick is passing
dest.branch into _safe_cherry_pick so conflict checks look for
source/<dest.branch>; change the call in _cherrypick_art_pull_request to pass
the PR's source/upstream branch (use pull_request.head.ref) as source_branch
instead of dest.branch so _safe_cherry_pick inspects source/<pr-branch>. Also
update the other occurrence referenced (around line 963) to the same pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@rebasebot/bot.py`:
- Around line 287-292: The current try/except around
git.show(f"{source_ref}:{f}") and git.show(f"HEAD:{f}") swallows GitCommandError
for either side; change it to call the two git.show calls separately so you can
detect the case where upstream_content exists but current_content (HEAD:{f})
raises GitCommandError — treat that as content-loss (e.g., set current_content =
"" or mark the file as lost so downstream delete/rename that won the merge is
considered content loss) instead of continuing; update the logic that uses
upstream_content/current_content (the code handling f after this block) to
handle the empty-current or “lost” flag and trigger warn/strict accordingly.

---

Outside diff comments:
In `@rebasebot/bot.py`:
- Around line 542-570: The ART cherry-pick is passing dest.branch into
_safe_cherry_pick so conflict checks look for source/<dest.branch>; change the
call in _cherrypick_art_pull_request to pass the PR's source/upstream branch
(use pull_request.head.ref) as source_branch instead of dest.branch so
_safe_cherry_pick inspects source/<pr-branch>. Also update the other occurrence
referenced (around line 963) to the same pattern.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a684f2b3-9a8e-4cc1-bbdd-871071849c51

📥 Commits

Reviewing files that changed from the base of the PR and between 6f0004b and 9bf5660.

📒 Files selected for processing (4)
  • rebasebot/bot.py
  • rebasebot/cli.py
  • tests/test_conflict_policy.py
  • tests/test_rebases.py

Comment on lines +287 to +292
try:
upstream_content = gitwd.git.show(f"{source_ref}:{f}")
current_content = gitwd.git.show(f"HEAD:{f}")
except git.GitCommandError:
# File doesn't exist on one side — not a content loss scenario
continue
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Handle deleted conflicted files as content loss.

If HEAD:{file} no longer exists after -Xtheirs, this currently gets skipped as “not a content loss scenario”. That misses the exact case where a downstream delete/rename wins a conflict and drops all upstream content from the file, so warn/strict will silently pass.

Possible fix
     for f in files_to_check:
         try:
             upstream_content = gitwd.git.show(f"{source_ref}:{f}")
-            current_content = gitwd.git.show(f"HEAD:{f}")
         except git.GitCommandError:
-            # File doesn't exist on one side — not a content loss scenario
             continue
+
+        try:
+            current_content = gitwd.git.show(f"HEAD:{f}")
+        except git.GitCommandError:
+            # The file existed upstream but not after the cherry-pick.
+            results.append((f, upstream_content.splitlines()))
+            continue
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rebasebot/bot.py` around lines 287 - 292, The current try/except around
git.show(f"{source_ref}:{f}") and git.show(f"HEAD:{f}") swallows GitCommandError
for either side; change it to call the two git.show calls separately so you can
detect the case where upstream_content exists but current_content (HEAD:{f})
raises GitCommandError — treat that as content-loss (e.g., set current_content =
"" or mark the file as lost so downstream delete/rename that won the merge is
considered content loss) instead of continuing; update the logic that uses
upstream_content/current_content (the code handling f after this block) to
handle the empty-current or “lost” flag and trigger warn/strict accordingly.

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

Labels

ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cherry-pick -Xtheirs silently drops upstream additions on conflict

4 participants