Skip to content

feat: add fix tag judge to find whether in downstream kernel.#10

Merged
LeiGuo622 merged 1 commit into
mainfrom
feat/fix-tag-detection
Apr 8, 2026
Merged

feat: add fix tag judge to find whether in downstream kernel.#10
LeiGuo622 merged 1 commit into
mainfrom
feat/fix-tag-detection

Conversation

@LeiGuo622
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings April 8, 2026 14:08
@LeiGuo622 LeiGuo622 merged commit 8eed1bd into main Apr 8, 2026
3 checks passed
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 a “fix tag” pre-check to the kernel commit prejudge flow, intended to detect whether introducing/fix-related commits are present in a downstream target kernel before running CONFIG analysis.

Changes:

  • Extend PrejudgeController to accept a target_project_dir and gate config analysis on a new judge_fix() result.
  • Add FixCommitAnalyzer (judge_fix.py) to parse commit messages for fix-related commit IDs and check their presence in a target repo/branch.
  • Update prejudge.py CLI usage to require explicit kernel source and target project directories.

Reviewed changes

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

File Description
src/prejudge/prejudge.py Adds target-project directory support and integrates fix-commit gating before config judgment.
src/prejudge/judge_fix.py Introduces fix-commit extraction and downstream existence/branch checks via git commands.

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

Comment thread src/prejudge/prejudge.py
Comment on lines +74 to +75
except Exception:
# If check fails, log error but allow proceeding
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

judge_fix() claims it will “log error but allow proceeding”, but the exception handler silently returns True with no logging. This makes fix-tag gating failures invisible and can lead to unexpected true outputs. Consider either emitting the exception (at least to stderr) or updating the comment/behavior to match the intended UX.

Suggested change
except Exception:
# If check fails, log error but allow proceeding
except Exception as exc:
# If check fails, log error but allow proceeding
print(f"judge_fix failed for commit {commit_id}: {exc}", file=sys.stderr)

Copilot uses AI. Check for mistakes.
Comment thread src/prejudge/prejudge.py
Comment on lines +198 to 199
# No patch content, return error message
print("Error: Could not retrieve patch content. Please check the commit ID and repository.")
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

analyze_and_report() is documented to output only true or false, but when patch content can’t be retrieved it prints an error string instead. If callers parse stdout as a boolean, this is a breaking behavior change. Consider printing the error to stderr while still emitting false (or otherwise keep stdout strictly boolean).

Suggested change
# No patch content, return error message
print("Error: Could not retrieve patch content. Please check the commit ID and repository.")
# No patch content; keep stdout strictly boolean and send diagnostics to stderr
print("Error: Could not retrieve patch content. Please check the commit ID and repository.", file=sys.stderr)
print("false")

Copilot uses AI. Check for mistakes.
Comment thread src/prejudge/judge_fix.py
Comment on lines +186 to +194
"""Main entry point for standalone testing"""
if len(sys.argv) < 3:
print("Usage: judge_fix.py <commit-id> <src-project-dir> <target-project-dir>", file=sys.stderr)
sys.exit(1)

commit_id = sys.argv[1]
src_project_dir = sys.argv[2]
target_project_dir = sys.argv[3]

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The CLI arg validation is off-by-one: it checks len(sys.argv) < 3 but then reads sys.argv[3]. With only 2 args provided (commit-id + src-project-dir), this will raise IndexError instead of showing usage. The check should require 3 arguments after the script name (i.e., len(sys.argv) < 4).

Copilot uses AI. Check for mistakes.
Comment thread src/prejudge/judge_fix.py
Comment on lines +153 to +173
# Check each fix commit
results = []
all_exist = True
for fix_commit in fix_commits:
exists = self.check_commit_exists(fix_commit)
exists_in_olk = self.check_commit_in_branch(fix_commit)

results.append({
'commit_id': fix_commit,
'exists_in_repo': exists,
'exists_in_olk_6_6': exists_in_olk
})

if not exists:
all_exist = False

return {
'success': True,
'fix_commits': results,
'all_exist': all_exist,
'message': f'Found {len(fix_commits)} fix commit(s)'
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

analyze() computes exists_in_olk/exists_in_olk_6_6, but all_exist (and therefore should_proceed()) only considers exists_in_repo. This conflicts with the module docstring (“checks … exists in … OLK-6.6 branch”) and can allow proceeding even when the introducing commit is not in the downstream branch. Consider basing all_exist on the branch containment result (or updating the doc/outputs if repository-wide existence is the real criterion).

Copilot uses AI. Check for mistakes.
Comment thread src/prejudge/judge_fix.py
Comment on lines +106 to +109
# Check if the branch name is in the output
branches = result.stdout
return branch in branches

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

check_commit_in_branch() returns branch in result.stdout, which can produce false positives if another branch name contains the target as a substring (e.g., OLK-6.6-staging). Consider parsing the git branch --contains output line-by-line and comparing normalized branch names exactly (after stripping the leading * and whitespace).

Suggested change
# Check if the branch name is in the output
branches = result.stdout
return branch in branches
# Parse branch output line-by-line and compare normalized names exactly
for line in result.stdout.splitlines():
normalized_branch = line.strip()
if normalized_branch.startswith('*'):
normalized_branch = normalized_branch[1:].strip()
if normalized_branch == branch:
return True
return False

Copilot uses AI. Check for mistakes.
Comment thread src/prejudge/judge_fix.py
Comment on lines +49 to +68
def extract_fix_commits(self, commit_message: str) -> Set[str]:
"""
Extract fix commit IDs from commit message
Looks for patterns like:
- Fixes: <commit-id> ("description")
- Fix: <commit-id>
- Cc: <commit-id>
etc.
"""
fix_commits = set()

# Common patterns for fix tags
patterns = [
r'Fixes:\s+([0-9a-f]{7,40})',
r'Fix:\s+([0-9a-f]{7,40})',
r'fixes:\s+([0-9a-f]{7,40})',
r'fix:\s+([0-9a-f]{7,40})',
r'Commit:\s+([0-9a-f]{7,40})',
r'commit:\s+([0-9a-f]{7,40})',
]
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The docstring for extract_fix_commits() lists patterns like Cc: <commit-id>, but the implemented regex list only matches Fixes/Fix/Commit. Either expand the patterns to match what’s documented, or update the docstring to avoid misleading users about what tags are recognized.

Copilot uses AI. Check for mistakes.
@LeiGuo622 LeiGuo622 deleted the feat/fix-tag-detection branch April 9, 2026 11:28
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