Skip to content

Commit 18e4dc4

Browse files
committed
validate-pr: relax Launchpad link check; recognize UBUNTU-local commits
Two improvements addressing false-positive failures on tracked-branch PRs: 1. Launchpad bug link: drop the requirement that the URL appear on a line prefixed with 'BugLink:' or 'LP:'. The check now only ensures a https://bugs.launchpad.net/... URL exists somewhere in the PR body. Avoids false negatives when authors paste the link in prose. 2. UBUNTU-local commits (e.g. 'UBUNTU: [Config] ...', 'UBUNTU: [Packaging] ...', 'UBUNTU: SAUCE: ...') have no upstream equivalent and previously triggered R6 ("not SAUCE/Revert but has no upstream reference trailer"). Add an is_ubuntu_local() helper that matches the 'UBUNTU: ' prefix; exempt those commits from R6 and R9, label them [UBUNTU] in the digest table, and verify only the Signed-off-by trailer is present. Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
1 parent 68203dd commit 18e4dc4

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

.github/scripts/validate-pr

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ def get_backport_url(message):
4040
def is_sauce(subject):
4141
return bool(re.match(r'^NVIDIA:.*SAUCE:', subject))
4242

43+
def is_ubuntu_local(subject):
44+
"""Ubuntu-local commits with no upstream equivalent.
45+
46+
Catches 'UBUNTU: SAUCE: ...', 'UBUNTU: [Config] ...',
47+
'UBUNTU: [Packaging] ...', 'UBUNTU: Ubuntu-X.X.X-...', etc.
48+
"""
49+
return bool(re.match(r'^UBUNTU:\s', subject))
50+
4351
def is_revert(subject):
4452
return subject.startswith('Revert "')
4553

@@ -336,6 +344,9 @@ def build_digest(commits, repo, upstream_remote=None):
336344
# Strip outer Revert "..." wrapper and SAUCE prefix for display
337345
inner = re.sub(r'^Revert\s+"', '', subj).rstrip('"')
338346
display = _norm_sauce_subject(inner) or inner
347+
elif is_ubuntu_local(subj):
348+
kind = 'UBUNTU'
349+
display = re.sub(r'^UBUNTU:\s*', '', subj)
339350
else:
340351
kind = 'SAUCE'
341352
display = _norm_sauce_subject(subj) or subj
@@ -460,20 +471,24 @@ def lint_commits(commits):
460471

461472
# Classification for R6/R7/R9/R10
462473
sauce = is_sauce(subject)
474+
ubuntu = is_ubuntu_local(subject)
463475
revert = is_revert(subject)
464476

465-
# R9: subject length — exempt SAUCE and Reverts of SAUCE; the mandatory
466-
# "NVIDIA: [VR: ]SAUCE:" prefix already consumes 15–20 characters.
477+
# R9: subject length — exempt SAUCE, UBUNTU local and Reverts of SAUCE;
478+
# the mandatory "NVIDIA: [VR: ]SAUCE:" / "UBUNTU: [Config]" prefix
479+
# already consumes 12–20 characters.
467480
revert_of_sauce = revert and bool(re.match(r'^Revert "NVIDIA:.*SAUCE:', subject))
468-
if len(subject) > 72 and not sauce and not revert_of_sauce:
481+
if len(subject) > 72 and not sauce and not ubuntu and not revert_of_sauce:
469482
warnings.append("W: {}: subject {} chars (>72)".format(label, len(subject)))
470483
cp_sha = get_cherry_pick_sha(commit.message)
471484
bp_url = get_backport_url(commit.message)
472485

473-
# R6: non-SAUCE, non-Revert commits must have an upstream reference trailer
474-
if not sauce and not revert and cp_sha is None and bp_url is None:
486+
# R6: non-SAUCE, non-UBUNTU, non-Revert commits must have an upstream
487+
# reference trailer. UBUNTU local commits (e.g. UBUNTU: [Config]) have
488+
# no upstream equivalent.
489+
if not sauce and not ubuntu and not revert and cp_sha is None and bp_url is None:
475490
errors.append(
476-
"E: {}: not SAUCE/Revert but has no upstream reference trailer"
491+
"E: {}: not SAUCE/UBUNTU/Revert but has no upstream reference trailer"
477492
" (cherry picked from commit ... or backported from ...)".format(label))
478493

479494
# R7: detect wrong trailer for LKML in-review backports
@@ -508,19 +523,18 @@ def check_pr_metadata(pr_title, pr_body_path, base_branch):
508523
warnings.append(
509524
"W: PR title missing [<branch>] prefix: \"{}\"".format(pr_title[:80]))
510525

511-
# R3: BugLink required for tracked branches
526+
# R3: Launchpad bug link required for tracked branches
512527
if pr_body_path and base_branch and TRACKED_BRANCH_RE.match(base_branch):
513528
try:
514529
body = open(pr_body_path).read()
515530
except OSError as e:
516531
errors.append("E: cannot read --pr-body {}: {}".format(pr_body_path, e))
517532
body = ''
518-
buglink_re = re.compile(
519-
r'^(?:BugLink:|LP:)\s+https://bugs\.launchpad\.net/', re.MULTILINE)
533+
buglink_re = re.compile(r'https://bugs\.launchpad\.net/')
520534
if not buglink_re.search(body):
521535
errors.append(
522-
"E: PR targets {} but body has no 'BugLink:' or 'LP:'"
523-
" https://bugs.launchpad.net/... line".format(base_branch))
536+
"E: PR targets {} but body has no"
537+
" https://bugs.launchpad.net/... link".format(base_branch))
524538

525539
return warnings, errors
526540

0 commit comments

Comments
 (0)