Skip to content

feat: add architecture support validation for backport judgment#11

Merged
LeiGuo622 merged 1 commit into
mainfrom
feat/arch-support-validation
Apr 9, 2026
Merged

feat: add architecture support validation for backport judgment#11
LeiGuo622 merged 1 commit into
mainfrom
feat/arch-support-validation

Conversation

@LeiGuo622
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings April 9, 2026 11:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an architecture-specific change filter to the pre-judging flow so backport decisions can be rejected when a commit modifies unsupported arch/* code.

Changes:

  • Introduce ArchAnalyzer to detect arch/<arch>/... modifications and verify they’re within an allowlist of supported downstream architectures.
  • Integrate a new “architecture supported” gate into PrejudgeController.analyze_and_report() after config enablement checks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/prejudge/prejudge.py Adds judge_arch() and wires an additional architecture-support validation step into the final true/false output.
src/prejudge/judge_arch.py New analyzer that lists files changed by a commit and determines whether any arch/* changes target unsupported architectures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +35 to +54
def get_patch_files(self, commit_id: str) -> List[str]:
"""
Get list of files modified by a commit
Returns list of file paths
"""
try:
result = subprocess.run(
['git', 'show', '--name-only', '--pretty=format:', commit_id],
cwd=self.kernel_dir,
capture_output=True,
text=True,
timeout=10
)

if result.returncode != 0:
return []

# Filter out empty lines
files = [f.strip() for f in result.stdout.splitlines() if f.strip()]
return files
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

get_patch_files() passes commit_id directly to git show. Since commit_id is user-provided (CLI arg via prejudge.py), a value starting with - (or a crafted revspec) can be interpreted as a git option/revspec and produce unexpected behavior. Consider validating commit_id up-front (e.g., only allow SHA-1/short SHA patterns, or resolve with git rev-parse --verify <id>^{commit}) and fail the analysis explicitly when validation fails.

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +72
def get_arch_from_path(self, file_path: str) -> str:
"""
Extract architecture name from file path
Returns the architecture name if the file is under arch/, None otherwise
"""
# Check if file is under arch/ directory
if file_path.startswith('arch/'):
# Extract architecture name
# Format: arch/<arch_name>/...
match = re.match(r'arch/([^/]+)', file_path)
if match:
return match.group(1)

return None
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

get_arch_from_path() is annotated to return str but it returns None when the path is not under arch/. Please update the return type to Optional[str] (or str | None on Python 3.10+) to match actual behavior and avoid type-checking/runtime confusion.

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +13
import subprocess
from pathlib import Path
from typing import Set, List
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

Set is imported from typing but not used in this module. Please remove the unused import to keep linting clean.

Copilot uses AI. Check for mistakes.
@LeiGuo622 LeiGuo622 merged commit cb66d0a into main Apr 9, 2026
5 checks passed
@LeiGuo622 LeiGuo622 deleted the feat/arch-support-validation branch April 12, 2026 13:55
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.

2 participants