Skip to content

Add script to validate upstream references in PR branch commits #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2025

Conversation

bmastbergen
Copy link
Collaborator

@bmastbergen bmastbergen commented Jun 11, 2025

This script scans each commit in a PR branch for upstream Linux kernel commit references and validates those references. If a commit references an upstream commit, the script checks that the referenced commit exists in mainline and reports if it has been marked with a Fixes: tag in the upstream kernel.

Usage:
python3 check_kernel_commits.py --repo path --pr_branch branch_name --base_branch branch_name [--markdown]

By default, the script outputs results for terminal display. Use the --markdown flag to format output for GitHub PR comments.

This kernel-src-tree PR ctrliq/kernel-src-tree#323 includes a github action that uses this script to comment on the PR. There is a lot of messy history in the PR due to testing, but the interesting thing to look at is the github action ctrliq/kernel-src-tree@b82196f and the comment that the github actions bot made flagging the bogus upstream commit reference and available upstream fixes

Copilot

This comment was marked as outdated.

@bmastbergen bmastbergen force-pushed the check_kernel_commits branch from 19700ef to 2198c68 Compare June 11, 2025 19:49
Copy link
Collaborator

@PlaidCat PlaidCat left a comment

Choose a reason for hiding this comment

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

I think this is Great maybe just some cleanups

@bmastbergen bmastbergen force-pushed the check_kernel_commits branch 3 times, most recently from c87fea4 to 1144d0b Compare June 12, 2025 20:18
@bmastbergen
Copy link
Collaborator Author

So this might be a problem with vibe coding, or maybe more specifically with me vibe coding. The git cat-file method for verifying upstream commits exist was not actually working in what I checked in. Not sure how I got to that point because the script was definitely able to find bogus commits at one point. In the current version that function is now using git merge-base --is-ancestor which seems to work and is perhaps easier to reason about by the casual observer anyway. 🤷‍♂️

@bmastbergen bmastbergen requested a review from PlaidCat June 27, 2025 14:14
@bmastbergen
Copy link
Collaborator Author

So this might be a problem with vibe coding, or maybe more specifically with me vibe coding. The git cat-file method for verifying upstream commits exist was not actually working in what I checked in. Not sure how I got to that point because the script was definitely able to find bogus commits at one point. In the current version that function is now using git merge-base --is-ancestor which seems to work and is perhaps easier to reason about by the casual observer anyway. 🤷‍♂️

Just so its clear. The code is working as is. So review away.

Copy link

@Copilot 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

This PR adds a Python script to validate upstream Linux kernel commit references in PR branch commits. The script checks if referenced commits exist in mainline and reports any that have been marked with Fixes: tags.

  • Adds check_kernel_commits.py with functionality to parse PR commits, validate upstream references, and detect fixes
  • Supports both terminal and markdown output formats for GitHub PR integration
  • Includes comprehensive error handling and reference validation

This script scans each commit in a PR branch for upstream Linux kernel
commit references and validates those references. If a commit references
an upstream commit, the script checks that the referenced commit exists
in mainline and reports if it has been marked with a Fixes: tag in the
upstream kernel.

Usage:
python3 check_kernel_commits.py --repo path --pr_branch branch_name --base_branch branch_name [--markdown]

By default, the script outputs results for terminal display. Use the
--markdown flag to format output for GitHub PR comments.
@bmastbergen bmastbergen force-pushed the check_kernel_commits branch from 1144d0b to 6300ec6 Compare August 8, 2025 16:30
@bmastbergen
Copy link
Collaborator Author

Just force pushed to incorporate some improvements suggested by copilot

Copy link
Collaborator

@PlaidCat PlaidCat left a comment

Choose a reason for hiding this comment

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

Thanks for all the updates.

:shipit:

We can improve it later if needed

@bmastbergen bmastbergen merged commit 55a2b22 into mainline Aug 8, 2025
@bmastbergen bmastbergen deleted the check_kernel_commits branch August 8, 2025 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants