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
-
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.
-
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.
-
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
Describe the bug
The
AzdevStyleModifiedExtensionsandAzdevLinterModifiedExtensionspipeline jobs report files unrelated to the current PR. This is caused by two issues in howfind_modified_files_against_master_branch()inazdev_linter_style.pycomputes the diff.Root Cause
Missing
git fetchfor 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, soorigin/<target_branch>may be stale or absent. Compare to theAzdevScanModifiedExtensionsjobs (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.
No
merge-baseused. The function diffs directly againstorigin/<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.
No guard for unset env var.
os.environ.get('ADO_PULL_REQUEST_TARGET_BRANCH')returnsNonewhen unset, producingorigin/None. The sibling scripttest_source.py(line 46) checks for the unexpanded ADO macro$(System.PullRequest.TargetBranch)and skips gracefully; this script does not.Affected Jobs
AzdevStyleModifiedExtensionsAzdevLinterModifiedExtensionsRelated command
N/A
Errors
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