Skip to content

CI: Linter/style checks pick up unrelated files due to missing git fetch and no merge-base #9714

Open

Description

@FumingZhang

Describe the bug

The AzdevStyleModifiedExtensions and AzdevLinterModifiedExtensions pipeline jobs report files unrelated to the current PR. This is caused by two issues in how find_modified_files_against_master_branch() in azdev_linter_style.py computes the diff.

Root Cause

  1. Missing git fetch for the target branch. The linter and style jobs in azure-pipelines.yml never fetch the target branch before running the diff. ADO uses a shallow clone, so origin/<target_branch> may be stale or absent. Compare to the AzdevScanModifiedExtensions jobs (lines 193, 224) which correctly do:
    - bash: git fetch origin --depth=1 $(System.PullRequest.TargetBranch)
    The linter job (line ~157) and style job (line ~131) skip this step entirely.

  2. No merge-base used. The function diffs directly against origin/<target_branch>:
    cmd = 'git --no-pager diff --name-only --diff-filter=ACMRT {} -- src/'.format(ado_pr_target_branch)
    If the target branch has advanced since the PR branch was created, this diff includes changes made on the target branch itself (not part of the PR). The correct approach is to diff against the merge-base of HEAD and the target branch.

  3. No guard for unset env var. os.environ.get('ADO_PULL_REQUEST_TARGET_BRANCH') returns None when unset, producing origin/None. The sibling script test_source.py (line 46) checks for the unexpanded ADO macro $(System.PullRequest.TargetBranch) and skips gracefully; this script does not.

Affected Jobs

  • AzdevStyleModifiedExtensions
  • AzdevLinterModifiedExtensions

Related command

N/A

Errors

AZURE_EXTENSION_DIR=~/.azure/cliextensions python scripts/ci/azdev_linter_style.py --type style
azdev type: style
----------------------------------------------------------------------------------------------------
pull request target branch: origin/main
modified files:
----------------------------------------------------------------------------------------------------
src/aks-preview/HISTORY.rst
src/aks-preview/azcli_aks_live_test/configs/ext_matrix_default.json
src/aks-preview/azext_aks_preview/_consts.py
src/aks-preview/azext_aks_preview/_help.py
src/aks-preview/azext_aks_preview/_params.py
src/aks-preview/azext_aks_preview/agentpool_decorator.py
src/aks-preview/azext_aks_preview/custom.py
src/aks-preview/azext_aks_preview/tests/latest/test_agentpool_decorator.py
src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py
src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py
src/index.json
src/oracle-database/HISTORY.rst
src/oracle-database/azext_oracle_database/aaz/latest/oracle_database/autonomous_database/_list.py
src/oracle-database/azext_oracle_database/tests/latest/test_oracle_database_adbs.py
src/oracle-database/setup.py

https://dev.azure.com/azclitools/public/_build/results?buildId=304376&view=logs&j=506b8f13-8269-5210-246e-a3964e53141e&t=db7247cb-300d-5b59-fd6c-6258fad20b89

where the origin branch of PR #9704 does not touch the index.json or oracle-database related files

Issue script & Debug output

N/A

Expected behavior

Changes should not be included if the modified files are unrelated to the PR.

Environment Summary

N/A

Additional context

No response

Activity

  1. added
    bugThis issue requires a change to an existing behavior in the product in order to be resolved.
    on Mar 24, 2026
  2. yonzhan commented on Mar 24, 2026

    @yonzhan
    Collaborator

    Thank you for opening this issue, we will look into it.

  3. necusjz commented on Mar 24, 2026

    @necusjz
    Member

    thanks for figuring out, we'll fix it shortly.

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

Metadata

Metadata

Labels

Azure CLI TeamThe command of the issue is owned by Azure CLI teambugThis issue requires a change to an existing behavior in the product in order to be resolved.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions