Skip to content

fix(azure): use last_merge_source_commit for PR head SHA#2321

Open
gvago wants to merge 1 commit intomainfrom
fix/azure-head-sha-regression
Open

fix(azure): use last_merge_source_commit for PR head SHA#2321
gvago wants to merge 1 commit intomainfrom
fix/azure-head-sha-regression

Conversation

@gvago
Copy link
Copy Markdown

@gvago gvago commented Apr 14, 2026

Summary

  • Fix incorrect diff computation in Azure DevOps provider caused by using last_merge_commit (a merge commit) instead of last_merge_source_commit (the actual source branch head) for the PR head SHA.
  • Uses getattr with a fallback to last_merge_commit to handle cases where last_merge_source_commit is not available.

Test plan

  • Verify Azure DevOps PRs produce correct diffs by comparing head_sha before/after the fix
  • Confirm fallback works when last_merge_source_commit is None or absent

🤖 Generated with Claude Code

The code was using `last_merge_commit` which points to a merge commit (or
differs from the source branch head), causing incorrect diff computation.
Switch to `last_merge_source_commit` to get the actual source branch tip,
with a fallback to `last_merge_commit` when the attribute is unavailable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Fix Azure DevOps PR head SHA to use source commit

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Fix incorrect PR head SHA computation in Azure DevOps provider
• Use last_merge_source_commit instead of last_merge_commit
• Add fallback to last_merge_commit for backward compatibility
Diagram
flowchart LR
  A["Azure PR Object"] -->|"Previously used"| B["last_merge_commit<br/>merge commit"]
  A -->|"Now uses"| C["last_merge_source_commit<br/>source branch tip"]
  C -->|"Fallback to"| B
  B --> D["Correct Diff Computation"]
  C --> D
Loading

Grey Divider

File Changes

1. pr_agent/git_providers/azuredevops_provider.py 🐞 Bug fix +1/-1

Use source commit for PR head SHA with fallback

• Changed head_sha assignment from self.pr.last_merge_commit to `getattr(self.pr,
 'last_merge_source_commit', None) or self.pr.last_merge_commit`
• Prioritizes last_merge_source_commit (actual source branch head) for accurate diff computation
• Maintains backward compatibility with fallback to last_merge_commit when attribute is
 unavailable

pr_agent/git_providers/azuredevops_provider.py


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

qodo-free-for-open-source-projects bot commented Apr 14, 2026

Code Review by Qodo

🐞 Bugs (0)   📘 Rule violations (1)   📎 Requirement gaps (0)
📘\ ⚙ Maintainability (1)

Grey Divider


Remediation recommended

1. Single quotes in getattr 📘
Description
The new code uses single quotes in getattr(self.pr, 'last_merge_source_commit', None), diverging
from the project’s preferred double-quote string style in modified code. This can create
inconsistent formatting and noisy diffs against the repository’s stated conventions.
Code

pr_agent/git_providers/azuredevops_provider.py[201]

+            head_sha = getattr(self.pr, 'last_merge_source_commit', None) or self.pr.last_merge_commit
Evidence
PR Compliance ID 9 requires adhering to the project’s formatting conventions, including preferential
use of double quotes in modified code. The changed line introduces a single-quoted string literal
for the attribute name.

AGENTS.md
pr_agent/git_providers/azuredevops_provider.py[201-201]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The modified line uses single quotes for the string literal passed to `getattr`, which conflicts with the repo’s preferred double-quote convention in changed code.

## Issue Context
This PR changed the `head_sha` computation line in the Azure DevOps provider.

## Fix Focus Areas
- pr_agent/git_providers/azuredevops_provider.py[201-201]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

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.

1 participant