Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Thunderbird/scripts/ci/   (Thunderbird Email Client Version 5.6©)  Datei vom 22.9.2026 mit Größe 1 kB image not shown  

Quelle  validate-pr-report-labels.sh   Sprache: Shell

 

#!/usr/bin/env bash

set -euo pipefail

# This script validates that a pull request has the required report labels.
# It uses the GitHub CLI (gh) to fetch PR information, allowing it to be tested locally.
#
# Usage:
#   ./validate-pr-report-labels.sh <pr-number>

if [[ $# -ne 1 ]]; then
    echo "Usage: $0 <pr-number>"
    exit 1
fi

PR_NUMBER="$1"

pr_data=$(gh pr view "$PR_NUMBER" --json labels,body)

labels_json=$(echo "$pr_data" | jq '.labels')
pr_body=$(echo "$pr_data" | jq -r '.body')

echo "Current labels:"
echo "$labels_json" | jq -r '.[].name'

include_count="$(jq '[.[] | select(.name == "report: include")] | length' <<< "$labels_json")"
exclude_count="$(jq '[.[] | select(.name == "report: exclude")] | length' <<< "$labels_json")"
highlight_count="$(jq '[.[] | select(.name == "report: highlight")] | length' <<< "$labels_json")"

total_count=$((include_count + exclude_count + highlight_count))

if [ "$total_count" -eq 0 ]; then
    echo "valid=false"
    echo "message=Missing report label. Set exactly one of: \`report: include\`, \`report: exclude\` OR \`report: highlight\`."
    exit 0
elif [ "$total_count" -gt 1 ]; then
    echo "valid=false"
    echo "message=Only one report label is allowed: \`report: include\`, \`report: exclude\` OR \`report: highlight\`."
    exit 0
fi

feature_flag_count="$(jq '[.[] | select(.name == "feature-flag")] | length' <<< "$labels_json")"
if [ "$feature_flag_count" -gt 0 ]; then
    pr_feature_flag_key="$(jq -nr --arg body "$pr_body" '
      try (
        $body
        | split("\n")
        | .[]
        | sub("^\\s+"; "")
        | select(test("^feature-flag:\\s*`[^`]+`"; "i"))
        | capture("`(?<flag>[^`]+)`")
        | .flag
      ) catch ""
    ' | head -n 1)"

    if [ -z "$pr_feature_flag_key" ]; then
        echo "valid=false"
        echo "message=PR body must contain the feature flag key in the format: 'feature-flag: \`<feature-flag-key>\`'."
        exit 0
    fi
fi

echo "valid=true"

Messung
CHZG
839610093

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-04) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.