[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][base-browser-147.0a1-16.0-2] fixup! BB 42683: Create script to generate issue triage csv file from bugzilla query and git logs



Title: GitLab

Pier Angelo Vendrame pushed to branch base-browser-147.0a1-16.0-2 at The Tor Project / Applications / Tor Browser

Commits:

  • f54e79d0
    by Pier Angelo Vendrame at 2026-02-05T19:14:32+01:00
    fixup! BB 42683: Create script to generate issue triage csv file from bugzilla query and git logs
    
    Delete the script that has been moved to
    tor-browser-build:tools/browser.
    

1 changed file:

Changes:

  • tools/torbrowser/generate-bugzilla-triage-csv.sh deleted
    1
    -#!/usr/bin/env bash
    
    2
    -
    
    3
    -# prints to stderr
    
    4
    -function echoerr() { echo "$@" 1>&2; }
    
    5
    -
    
    6
    -# help dialog
    
    7
    -if [ "$#" -lt 5 ]; then
    
    8
    -    echoerr "Usage: $0 ff-version begin-commit end-commit gitlab-audit-issue reviewers..."
    
    9
    -    echoerr ""
    
    10
    -    echoerr "Writes a CSV to stdout of Bugzilla issues to triage for a particular Firefox version. This"
    
    11
    -    echoerr "script performs a union of the labeled Bugzilla issues in Mozilla's issue tracker and the"
    
    12
    -    echoerr "labeled commits in the provided commit range"
    
    13
    -    echoerr
    
    14
    -    echoerr "    ff-version             rapid-release Firefox version to audit"
    
    15
    -    echoerr "    begin-commit           starting gecko-dev commit of this Firefox version"
    
    16
    -    echoerr "    end-commit             ending gecko-dev commit of this Firefox version"
    
    17
    -    echoerr "    gitlab-audit-issue     tor-browser-spec Gitlab issue number for this audit"
    
    18
    -    echoerr "    reviewers...           space-separated list of reviewers responsible for this audit"
    
    19
    -    echoerr ""
    
    20
    -    echoerr "Example:"
    
    21
    -    echoerr ""
    
    22
    -    echoerr "$0 116 FIREFOX_ESR_115_BASE FIREFOX_116_0_3_RELEASE 40064 richard pierov henry"
    
    23
    -    exit 1
    
    24
    -fi
    
    25
    -
    
    26
    -# set -x
    
    27
    -set -e
    
    28
    -
    
    29
    -
    
    30
    -# Ensure various required tools are available
    
    31
    -function check_exists() {
    
    32
    -    local cmd=$1
    
    33
    -    if ! which ${cmd} > /dev/null ; then
    
    34
    -        echoerr "missing ${cmd} dependency"
    
    35
    -        exit 1
    
    36
    -    fi
    
    37
    -}
    
    38
    -
    
    39
    -check_exists git
    
    40
    -check_exists jq
    
    41
    -check_exists mktemp
    
    42
    -check_exists perl
    
    43
    -check_exists printf
    
    44
    -check_exists sed
    
    45
    -check_exists sort
    
    46
    -check_exists touch
    
    47
    -check_exists uniq
    
    48
    -check_exists wget
    
    49
    -
    
    50
    -# Assign arguments to named variables
    
    51
    -firefox_version=$1
    
    52
    -git_begin=$2
    
    53
    -git_end=$3
    
    54
    -audit_issue=$4
    
    55
    -reviewers="${@:5}"
    
    56
    -
    
    57
    -# Check valid Firefox version
    
    58
    -if ! [[ "${firefox_version}" =~ ^[1-9][0-9]{2}$ ]]; then
    
    59
    -    echoerr "invalid Firefox version (probably)"
    
    60
    -    exit 1
    
    61
    -fi
    
    62
    -
    
    63
    -# Check valid Gitlab issue number
    
    64
    -if ! [[ "${audit_issue}" =~ ^[1-9][0-9]{4}$ ]]; then
    
    65
    -    echoerr "invalid gitlab audit issue number (probably)"
    
    66
    -    exit 1
    
    67
    -fi
    
    68
    -
    
    69
    -#
    
    70
    -# Encoding/Decoding Functions
    
    71
    -#
    
    72
    -
    
    73
    -# escape " and \
    
    74
    -function json_escape() {
    
    75
    -    local input="$1"
    
    76
    -    echo "${input}" | sed 's/["\]/\\"/g'
    
    77
    -}
    
    78
    -
    
    79
    -
    
    80
    -# un-escape \"
    
    81
    -function jq_unescape() {
    
    82
    -    local input="$1"
    
    83
    -    echo "${input}" | sed 's/\\"/"/g'
    
    84
    -}
    
    85
    -
    
    86
    -# change quotes to double-quotes
    
    87
    -function csv_escape() {
    
    88
    -    local input="$1"
    
    89
    -    echo "${input}" | sed 's/"/""/g'
    
    90
    -}
    
    91
    -
    
    92
    -# we need to urlencode the strings used in the new issue link
    
    93
    -function url_encode() {
    
    94
    -    local input="$1"
    
    95
    -    echo "${input}" | perl -MURI::Escape -wlne 'print uri_escape $_'
    
    96
    -}
    
    97
    -
    
    98
    -
    
    99
    -#
    
    100
    -# Create temp json files
    
    101
    -#
    
    102
    -git_json=$(mktemp -t git-audit-${firefox_version}-XXXXXXXXXXX.json)
    
    103
    -bugzilla_json=$(mktemp -t bugzilla-audit-${firefox_version}-XXXXXXXXXXX.json)
    
    104
    -union_json=$(mktemp -t union-audit-${firefox_version}-XXXXXXXXXXX.json)
    
    105
    -touch "${git_json}"
    
    106
    -touch "${bugzilla_json}"
    
    107
    -touch "${union_json}"
    
    108
    -
    
    109
    -function json_cleanup {
    
    110
    -    rm -f "${git_json}"
    
    111
    -    rm -f "${bugzilla_json}"
    
    112
    -    rm -f "${union_json}"
    
    113
    -}
    
    114
    -trap json_cleanup EXIT
    
    115
    -
    
    116
    -#
    
    117
    -# Generate Git Commit Triage List
    
    118
    -#
    
    119
    -
    
    120
    -# Try and extract bug id and summary from git log
    
    121
    -# Mozilla's commits are not always 100% consistently named, so this
    
    122
    -# regex is a bit flexible to handle various inputs such as:
    
    123
    -# "Bug 1234 -", "Bug 1234:", "Bug Bug 1234 -", "[Bug 1234] -", " bug 1234 -".
    
    124
    -sed_extract_id_summary="s/^[[ ]*[bug –-]+ ([1-9][0-9]*)[]:\., –-]*(.*)\$/\\1 \\2/pI"
    
    125
    -
    
    126
    -# Generate a json array of objects in the same format as bugzilla: {id: number, summary: string}
    
    127
    -printf "[\n" >> "${git_json}"
    
    128
    -
    
    129
    -first_object=true
    
    130
    -git log --format='%s' $git_begin..$git_end  \
    
    131
    -| sed -En "${sed_extract_id_summary}" \
    
    132
    -| sort -h \
    
    133
    -| uniq \
    
    134
    -| while IFS= read -r line; do
    
    135
    -    read -r id summary <<< "${line}"
    
    136
    -    summary=$(json_escape "${summary}")
    
    137
    -
    
    138
    -    # json does not allow trailing commas
    
    139
    -    if [[ "${first_object}" = true ]]; then
    
    140
    -        first_object=false
    
    141
    -    else
    
    142
    -        printf ",\n" >> "${git_json}"
    
    143
    -    fi
    
    144
    -
    
    145
    -    printf "  { \"id\": %s, \"summary\": \"%s\" }" ${id} "${summary}" >> "${git_json}"
    
    146
    -done
    
    147
    -printf "\n]\n" >> "${git_json}"
    
    148
    -
    
    149
    -#
    
    150
    -# Download Bugzilla Triage List
    
    151
    -#
    
    152
    -
    
    153
    -# search for:
    
    154
    -# + Product is NOT "Thunderbird,Calander,Chat Core,MailNews Core" (&f1=product&n1=1&o1=anyexact&v1=Thunderbird%2CCalendar%2CChat%20Core%2CMailNews%20Core). AND
    
    155
    -# + Target Milestone contains "${firefox_version}" (115 Branch or Firefox 115) (&f2=target_milestone&o2=substring&v2=${firefox_version}).
    
    156
    -# "&limit=0" shows all matching bugs.
    
    157
    -
    
    158
    -query_tail="&f1=product&n1=1&o1=anyexact&v1=Thunderbird%2CCalendar%2CChat%20Core%2CMailNews%20Core&f2=target_milestone&o2=substring&v2=${firefox_version}&limit=0"
    
    159
    -
    
    160
    -bugzilla_query="https://bugzilla.mozilla.org/buglist.cgi?${query_tail}"
    
    161
    -bugzilla_json_query="https://bugzilla.mozilla.org/rest/bug?include_fields=id,component,summary${query_tail}"
    
    162
    -
    
    163
    -wget "${bugzilla_json_query}" -O ${bugzilla_json}
    
    164
    -
    
    165
    -
    
    166
    -#
    
    167
    -# Create Union of these two sets of issues
    
    168
    -#
    
    169
    -
    
    170
    -# bugzilla array is actually on a root object: { bugs: [...] }
    
    171
    -jq -s '[ (.[0].bugs)[], (.[1])[] ] | group_by(.id) | map(.[0])' "${bugzilla_json}" "${git_json}" > "${union_json}"
    
    172
    -
    
    173
    -#
    
    174
    -# Generate Triage CSV
    
    175
    -#
    
    176
    -
    
    177
    -echo "\"Review\",,\"Bugzilla Component\",\"Bugzilla Bug\""
    
    178
    -
    
    179
    -jq '. | sort_by([.component, .id])[] | "\(.id)|\(.component)|\(.summary)"' ${union_json} \
    
    180
    -| while IFS='|' read -r id component summary; do
    
    181
    -
    
    182
    -    # bugzilla info
    
    183
    -    id="${id:1}"
    
    184
    -    component="${component:0}"
    
    185
    -    summary="${summary:0:-1}"
    
    186
    -    summary=$(jq_unescape "${summary}")
    
    187
    -    # short summary for gitlab issue title
    
    188
    -    [[ ${#summary} -gt 80 ]] && summary_short="${summary:0:77}..." || summary_short="${summary}"
    
    189
    -
    
    190
    -    # filter out some issue types that we never care about
    
    191
    -    skip_issue=false
    
    192
    -
    
    193
    -    # skip `[wpt-sync] Sync PR`
    
    194
    -    if [[ "${summary}" =~ ^\[wpt-sync\]\ Sync\ PR.*$ ]]; then
    
    195
    -        skip_issue=true
    
    196
    -    # skip `Crash in [@` and variants
    
    197
    -    elif [[ "${summary}" =~ ^Crash[esin\ ]*\ \[\@.*$ ]]; then
    
    198
    -        skip_issue=true
    
    199
    -    # skip `Assertion failuire: `
    
    200
    -    elif [[ "${summary}" =~ ^Assertion\ failure:\ .*$ ]]; then
    
    201
    -        skip_issue=true
    
    202
    -    # skip `Hit MOZ_CRASH`
    
    203
    -    elif [[ "${summary}" =~ ^Hit\ MOZ_CRASH.*$ ]]; then
    
    204
    -        skip_issue=true
    
    205
    -    fi
    
    206
    -
    
    207
    -    if [[ "${skip_issue}" = true ]]; then
    
    208
    -        echoerr "Skipped Bugzilla ${id}: ${summary_short}"
    
    209
    -    else
    
    210
    -        csv_summary=$(csv_escape "${summary}")
    
    211
    -        csv_component=$(csv_escape "${component}")
    
    212
    -
    
    213
    -        # parent issue
    
    214
    -        bugzilla_url="https://bugzilla.mozilla.org/show_bug.cgi?id=${id}"
    
    215
    -        # review issue title
    
    216
    -        new_issue_title=$(url_encode "Review Mozilla ${id}: ${summary_short}")
    
    217
    -        # review issue description + labeling (14.0 stable, FF128-esr, Next)
    
    218
    -        new_issue_description=$(url_encode "### Bugzilla: ${bugzilla_url}")%0A$(url_encode "/label ~\"14.0 stable\" ~FF128-esr ~Next")%0A$(url_encode "/relate tpo/applications/tor-browser-spec#${audit_issue}")%0A%0A$(url_encode "<!-- briefly describe why this issue needs further review -->")%0A
    
    219
    -        # url which create's new issue with title and description pre-populated
    
    220
    -        new_issue_url="https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/new?issue[title]=${new_issue_title}&issue[description]=${new_issue_description}"
    
    221
    -
    
    222
    -        # this link will start the creation of a new gitlab issue to review
    
    223
    -        create_issue=$(csv_escape "=HYPERLINK(\"${new_issue_url}\", \"New Issue\")")
    
    224
    -        bugzilla_link=$(csv_escape "=HYPERLINK(\"${bugzilla_url}\", \"Bugzilla ${id}: ${csv_summary}\")")
    
    225
    -
    
    226
    -        echo "FALSE,\"${create_issue}\",\"${csv_component}\",\"${bugzilla_link}\","
    
    227
    -    fi
    
    228
    -done
    
    229
    -
    
    230
    -echo
    
    231
    -echo "\"Triaged by:\""
    
    232
    -for reviewer in $reviewers; do
    
    233
    -    reviewer=$(csv_escape "${reviewer}")
    
    234
    -    echo "\"FALSE\",\"${reviewer}\""
    
    235
    -done
    
    236
    -echo
    
    237
    -
    
    238
    -bugzilla_query="=HYPERLINK(\"${bugzilla_query}\", \"Bugzilla query\")"
    
    239
    -echo \"$(csv_escape "${bugzilla_query}")\"

  • _______________________________________________
    tor-commits mailing list -- tor-commits@xxxxxxxxxxxxxxxxxxxx
    To unsubscribe send an email to tor-commits-leave@xxxxxxxxxxxxxxxxxxxx